|
@@ -173,7 +173,7 @@ namespace GFGGame
|
|
if (!string.IsNullOrEmpty(actionRes))
|
|
if (!string.IsNullOrEmpty(actionRes))
|
|
{
|
|
{
|
|
string resPath = ResPathUtil.GetDressUpAnimationPath(actionRes);
|
|
string resPath = ResPathUtil.GetDressUpAnimationPath(actionRes);
|
|
- if (CheckGameObjExisted(parentObj, BODY_ANIMATION_NAME, resPath))
|
|
|
|
|
|
+ if (GetGameObjExisted(parentObj, BODY_ANIMATION_NAME, resPath) != null)
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -181,7 +181,7 @@ namespace GFGGame
|
|
else
|
|
else
|
|
{
|
|
{
|
|
string resPath = ResPathUtil.GetDressUpPath(BODY_DEFAULT_RES_NAME, extPng);
|
|
string resPath = ResPathUtil.GetDressUpPath(BODY_DEFAULT_RES_NAME, extPng);
|
|
- if (CheckGameObjExisted(parentObj, BODY_SPRITE_NAME, resPath))
|
|
|
|
|
|
+ if (GetGameObjExisted(parentObj, BODY_SPRITE_NAME, resPath) != null)
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -271,7 +271,12 @@ namespace GFGGame
|
|
addAniObj = AddAnimationObj(res, objName, parentObj, sortingOrder);
|
|
addAniObj = AddAnimationObj(res, objName, parentObj, sortingOrder);
|
|
if (addAniObj != null && spriteObj != null)
|
|
if (addAniObj != null && spriteObj != null)
|
|
{
|
|
{
|
|
- Timers.inst.Add(0.03f, 1, (obj) =>
|
|
|
|
|
|
+ var dressUpPart = addAniObj.GetComponent<DressUpPart>();
|
|
|
|
+ if(dressUpPart == null)
|
|
|
|
+ {
|
|
|
|
+ dressUpPart = addAniObj.AddComponent<DressUpPart>();
|
|
|
|
+ }
|
|
|
|
+ dressUpPart.OnTimer = (obj) =>
|
|
{
|
|
{
|
|
if (parentObj != null && parentObj.transform != null)
|
|
if (parentObj != null && parentObj.transform != null)
|
|
{
|
|
{
|
|
@@ -292,7 +297,8 @@ namespace GFGGame
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- });
|
|
|
|
|
|
+ };
|
|
|
|
+ Timers.inst.Add(0.03f, 1, dressUpPart.OnTimer);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -308,12 +314,13 @@ namespace GFGGame
|
|
{
|
|
{
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
- if (CheckGameObjExisted(parentObj, objName, resPath))
|
|
|
|
|
|
+ var gameObj = GetGameObjExisted(parentObj, objName, resPath);
|
|
|
|
+ if (gameObj != null)
|
|
{
|
|
{
|
|
- return null;
|
|
|
|
|
|
+ return gameObj;
|
|
}
|
|
}
|
|
SpriteRenderer spr = null;
|
|
SpriteRenderer spr = null;
|
|
- var gameObj = parentObj.transform.Find(objName)?.gameObject;
|
|
|
|
|
|
+ gameObj = parentObj.transform.Find(objName)?.gameObject;
|
|
if (gameObj == null)
|
|
if (gameObj == null)
|
|
{
|
|
{
|
|
gameObj = new GameObject(objName);
|
|
gameObj = new GameObject(objName);
|
|
@@ -358,12 +365,13 @@ namespace GFGGame
|
|
{
|
|
{
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
- if(CheckGameObjExisted(parentObj, objName, resPath))
|
|
|
|
|
|
+ var gameObj = GetGameObjExisted(parentObj, objName, resPath);
|
|
|
|
+ if (gameObj != null)
|
|
{
|
|
{
|
|
- return null;
|
|
|
|
|
|
+ return gameObj;
|
|
}
|
|
}
|
|
var prefab = GFGAsset.Load<GameObject>(resPath);
|
|
var prefab = GFGAsset.Load<GameObject>(resPath);
|
|
- var gameObj = GameObject.Instantiate(prefab);
|
|
|
|
|
|
+ gameObj = GameObject.Instantiate(prefab);
|
|
AddAssetReleaser(gameObj, resPath);
|
|
AddAssetReleaser(gameObj, resPath);
|
|
if (objName == BODY_ANIMATION_NAME)
|
|
if (objName == BODY_ANIMATION_NAME)
|
|
{
|
|
{
|
|
@@ -390,19 +398,20 @@ namespace GFGGame
|
|
return gameObj;
|
|
return gameObj;
|
|
}
|
|
}
|
|
|
|
|
|
- private static void TryAddEffectObj(string res, string objName, GameObject parentObj, int sortingOrder, bool inAniDir)
|
|
|
|
|
|
+ private static GameObject TryAddEffectObj(string res, string objName, GameObject parentObj, int sortingOrder, bool inAniDir)
|
|
{
|
|
{
|
|
var resPath = ResPathUtil.GetDressUpEffectPath(res, inAniDir);
|
|
var resPath = ResPathUtil.GetDressUpEffectPath(res, inAniDir);
|
|
if (!VEngine.Versions.Contains(resPath))
|
|
if (!VEngine.Versions.Contains(resPath))
|
|
{
|
|
{
|
|
- return;
|
|
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
- if (CheckGameObjExisted(parentObj, objName, resPath))
|
|
|
|
|
|
+ var gameObj = GetGameObjExisted(parentObj, objName, resPath);
|
|
|
|
+ if (gameObj != null)
|
|
{
|
|
{
|
|
- return;
|
|
|
|
|
|
+ return gameObj;
|
|
}
|
|
}
|
|
GameObject effPre = GFGAsset.Load<GameObject>(resPath);
|
|
GameObject effPre = GFGAsset.Load<GameObject>(resPath);
|
|
- var gameObj = GameObject.Instantiate(effPre);
|
|
|
|
|
|
+ gameObj = GameObject.Instantiate(effPre);
|
|
AddAssetReleaser(gameObj, resPath);
|
|
AddAssetReleaser(gameObj, resPath);
|
|
gameObj.transform.SetParent(parentObj.transform, false);
|
|
gameObj.transform.SetParent(parentObj.transform, false);
|
|
gameObj.name = objName;
|
|
gameObj.name = objName;
|
|
@@ -412,6 +421,7 @@ namespace GFGGame
|
|
GameObject.Destroy(sortingGroup);
|
|
GameObject.Destroy(sortingGroup);
|
|
}
|
|
}
|
|
SetRenderersOrder(gameObj, sortingOrder + 1);//特效层默认高一个层级
|
|
SetRenderersOrder(gameObj, sortingOrder + 1);//特效层默认高一个层级
|
|
|
|
+ return gameObj;
|
|
}
|
|
}
|
|
|
|
|
|
private static bool TryRemoveObj(GameObject parentObj, string objName)
|
|
private static bool TryRemoveObj(GameObject parentObj, string objName)
|
|
@@ -433,11 +443,11 @@ namespace GFGGame
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- private static bool CheckGameObjExisted(GameObject parentObj, string objName, string resPath)
|
|
|
|
|
|
+ private static GameObject GetGameObjExisted(GameObject parentObj, string objName, string resPath)
|
|
{
|
|
{
|
|
if (parentObj == null)
|
|
if (parentObj == null)
|
|
{
|
|
{
|
|
- return false;
|
|
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
Transform transform = parentObj.transform.Find(objName);
|
|
Transform transform = parentObj.transform.Find(objName);
|
|
if (transform != null)
|
|
if (transform != null)
|
|
@@ -451,12 +461,12 @@ namespace GFGGame
|
|
if (assetReleaser.resPath == resPath)
|
|
if (assetReleaser.resPath == resPath)
|
|
{
|
|
{
|
|
|
|
|
|
- return true;
|
|
|
|
|
|
+ return gameObj;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return false;
|
|
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
|
|
|
|
public static GameObject CreateAnimationObj(string resPath)
|
|
public static GameObject CreateAnimationObj(string resPath)
|