|
@@ -209,12 +209,12 @@ namespace GFGGame
|
|
|
|
|
|
public static void AddAssetReleaser(GameObject gameObj, string resPath, AssetOperationHandle handle)
|
|
|
{
|
|
|
- var assetDisposer = gameObj.GetComponent<AssetReleaser>();
|
|
|
- if (assetDisposer == null)
|
|
|
+ var assetReleaser = gameObj.GetComponent<AssetReleaser>();
|
|
|
+ if (assetReleaser == null)
|
|
|
{
|
|
|
- assetDisposer = gameObj.AddComponent<AssetReleaser>();
|
|
|
+ assetReleaser = gameObj.AddComponent<AssetReleaser>();
|
|
|
}
|
|
|
- assetDisposer.SetRes(resPath, handle);
|
|
|
+ assetReleaser.SetRes(resPath, handle);
|
|
|
}
|
|
|
|
|
|
private static void updateLayerRes(ItemCfg itemCfg, GameObject parentObj, int layerId, bool needSetMask, bool showAni = true)
|
|
@@ -262,22 +262,29 @@ namespace GFGGame
|
|
|
{
|
|
|
if (parentObj != null && parentObj.transform != null)
|
|
|
{
|
|
|
- Transform tf = parentObj.transform.Find(spritObjName);
|
|
|
- if (tf != null && tf.gameObject != null && tf.gameObject.activeInHierarchy)
|
|
|
+ string resPath = ResPathUtil.GetDressUpPath(itemCfg, layerId);
|
|
|
+ spriteObj = GetGameObjExisted(parentObj, spritObjName, resPath);
|
|
|
+ if(spriteObj != null)
|
|
|
{
|
|
|
- var assetDisposer = tf.gameObject.GetComponent<AssetReleaser>();
|
|
|
- if (assetDisposer != null)
|
|
|
- {
|
|
|
- if (!string.IsNullOrEmpty(assetDisposer.resPath))
|
|
|
- {
|
|
|
- string resPath = ResPathUtil.GetDressUpPath(itemCfg, layerId);
|
|
|
- if (assetDisposer.resPath == resPath)
|
|
|
- {
|
|
|
- TryRemoveObj(parentObj, spritObjName);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ PrefabManager.Instance.Restore(spriteObj);
|
|
|
}
|
|
|
+
|
|
|
+ //Transform tf = parentObj.transform.Find(spritObjName);
|
|
|
+ //if (tf != null && tf.gameObject != null && tf.gameObject.activeInHierarchy)
|
|
|
+ //{
|
|
|
+ // var assetDisposer = tf.gameObject.GetComponent<AssetReleaser>();
|
|
|
+ // if (assetDisposer != null)
|
|
|
+ // {
|
|
|
+ // if (!string.IsNullOrEmpty(assetDisposer.resPath))
|
|
|
+ // {
|
|
|
+ // string resPath = ResPathUtil.GetDressUpPath(itemCfg, layerId);
|
|
|
+ // if (assetDisposer.resPath == resPath)
|
|
|
+ // {
|
|
|
+ // TryRemoveObj(parentObj, spritObjName);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
}
|
|
|
};
|
|
|
Timers.inst.Add(0.03f, 1, dressUpPart.OnTimer);
|
|
@@ -353,7 +360,7 @@ namespace GFGGame
|
|
|
{
|
|
|
return gameObj;
|
|
|
}
|
|
|
- gameObj = CreateAnimationObj(resPath);
|
|
|
+ gameObj = CreateObj(resPath);
|
|
|
if(gameObj == null)
|
|
|
{
|
|
|
return null;
|
|
@@ -391,7 +398,7 @@ namespace GFGGame
|
|
|
{
|
|
|
return gameObj;
|
|
|
}
|
|
|
- gameObj = CreateAnimationObj(resPath);
|
|
|
+ gameObj = CreateObj(resPath);
|
|
|
if (gameObj == null)
|
|
|
{
|
|
|
return null;
|
|
@@ -419,7 +426,7 @@ namespace GFGGame
|
|
|
GameObject gameObj = transform.gameObject;
|
|
|
if (gameObj != null)
|
|
|
{
|
|
|
- GameObject.DestroyImmediate(gameObj);
|
|
|
+ PrefabManager.Instance.Restore(gameObj);
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
@@ -441,9 +448,8 @@ namespace GFGGame
|
|
|
var assetReleaser = gameObj.GetComponent<AssetReleaser>();
|
|
|
if (assetReleaser != null)
|
|
|
{
|
|
|
- if (assetReleaser.resPath == resPath)
|
|
|
+ if (assetReleaser.ResPath == resPath)
|
|
|
{
|
|
|
-
|
|
|
return gameObj;
|
|
|
}
|
|
|
}
|
|
@@ -452,7 +458,7 @@ namespace GFGGame
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public static GameObject CreateAnimationObj(string resPath)
|
|
|
+ public static GameObject CreateObj(string resPath)
|
|
|
{
|
|
|
if (!YooAssets.CheckDressUpResExist(resPath))
|
|
|
{
|
|
@@ -460,7 +466,7 @@ namespace GFGGame
|
|
|
}
|
|
|
//var handle = YooAssets.LoadAssetSync<Sprite>(resPath);
|
|
|
//Sprite sp = handle.AssetObject as Sprite;
|
|
|
- var gameObj = GFGAsset.Load<GameObject>(resPath);
|
|
|
+ var gameObj = PrefabManager.Instance.SpawnSync(resPath);
|
|
|
//AddAssetReleaser(gameObj, resPath);
|
|
|
return gameObj;
|
|
|
}
|