|
@@ -92,62 +92,62 @@ namespace GFGGame
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public static void RemoveItem(int itemID, GameObject sceneObj, GameObject parentObj = null)
|
|
|
+ public static void RemoveItem(int itemID, GameObject parentObj)
|
|
|
{
|
|
|
ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemID);
|
|
|
- if (itemCfg != null)
|
|
|
+ if (itemCfg == null || parentObj== null) return;
|
|
|
+ string spritObjName;
|
|
|
+ string aniObjName;
|
|
|
+ //默认层
|
|
|
+ if (!string.IsNullOrEmpty(itemCfg.resLayer1))
|
|
|
+ {
|
|
|
+ spritObjName = string.Format(FORMAT_SPRITE_NAME, itemCfg.subType, 1);
|
|
|
+ TryRemoveSprite(parentObj, spritObjName);
|
|
|
+ aniObjName = string.Format(FORMAT_ANIMATION_NAME, itemCfg.subType, 1);
|
|
|
+ TryRemoveObj(parentObj, aniObjName);
|
|
|
+ aniObjName = string.Format(FORMAT_EFFECT_OBJ_NAME, itemCfg.subType, 1);
|
|
|
+ TryRemoveObj(parentObj, aniObjName);
|
|
|
+ }
|
|
|
+ //特殊层
|
|
|
+ if (!string.IsNullOrEmpty(itemCfg.resLayer2))
|
|
|
+ {
|
|
|
+ spritObjName = string.Format(FORMAT_SPRITE_NAME, itemCfg.subType, 2);
|
|
|
+ TryRemoveSprite(parentObj, spritObjName);
|
|
|
+ aniObjName = string.Format(FORMAT_ANIMATION_NAME, itemCfg.subType, 2);
|
|
|
+ TryRemoveObj(parentObj, aniObjName);
|
|
|
+ aniObjName = string.Format(FORMAT_EFFECT_OBJ_NAME, itemCfg.subType, 2);
|
|
|
+ TryRemoveObj(parentObj, aniObjName);
|
|
|
+ }
|
|
|
+ //第三层
|
|
|
+ if (!string.IsNullOrEmpty(itemCfg.resLayer3))
|
|
|
+ {
|
|
|
+ spritObjName = string.Format(FORMAT_SPRITE_NAME, itemCfg.subType, 3);
|
|
|
+ TryRemoveSprite(parentObj, spritObjName);
|
|
|
+ aniObjName = string.Format(FORMAT_ANIMATION_NAME, itemCfg.subType, 3);
|
|
|
+ TryRemoveObj(parentObj, aniObjName);
|
|
|
+ aniObjName = string.Format(FORMAT_EFFECT_OBJ_NAME, itemCfg.subType, 3);
|
|
|
+ TryRemoveObj(parentObj, aniObjName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static DressUpRemoveOperation RemoveItemAsync(int itemID, GameObject sceneObj, GameObject parentObj = null)
|
|
|
+ {
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemID);
|
|
|
+ if (itemCfg == null) return null;
|
|
|
+ if (parentObj == null)
|
|
|
{
|
|
|
- if (parentObj == null)
|
|
|
- {
|
|
|
- if (itemCfg.subType == ConstDressUpItemType.BEI_JING || DressUpMenuItemCfg1Array.Instance.CheckIsSceneTypeBySubType(itemCfg.subType))
|
|
|
- {
|
|
|
- parentObj = sceneObj;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //角色
|
|
|
- Transform role = sceneObj.transform.Find(ROLE_OBJ_NAME);
|
|
|
- parentObj = role.gameObject;
|
|
|
- }
|
|
|
- }
|
|
|
- string spritObjName;
|
|
|
- string aniObjName;
|
|
|
- //默认层
|
|
|
- if (!string.IsNullOrEmpty(itemCfg.resLayer1))
|
|
|
- {
|
|
|
- spritObjName = string.Format(FORMAT_SPRITE_NAME, itemCfg.subType, 1);
|
|
|
- TryRemoveSprite(parentObj, spritObjName);
|
|
|
- aniObjName = string.Format(FORMAT_ANIMATION_NAME, itemCfg.subType, 1);
|
|
|
- TryRemoveObj(parentObj, aniObjName);
|
|
|
- aniObjName = string.Format(FORMAT_EFFECT_OBJ_NAME, itemCfg.subType, 1);
|
|
|
- TryRemoveObj(parentObj, aniObjName);
|
|
|
- }
|
|
|
- //特殊层
|
|
|
- if (!string.IsNullOrEmpty(itemCfg.resLayer2))
|
|
|
+ if (itemCfg.subType == ConstDressUpItemType.BEI_JING || DressUpMenuItemCfg1Array.Instance.CheckIsSceneTypeBySubType(itemCfg.subType))
|
|
|
{
|
|
|
- spritObjName = string.Format(FORMAT_SPRITE_NAME, itemCfg.subType, 2);
|
|
|
- TryRemoveSprite(parentObj, spritObjName);
|
|
|
- aniObjName = string.Format(FORMAT_ANIMATION_NAME, itemCfg.subType, 2);
|
|
|
- TryRemoveObj(parentObj, aniObjName);
|
|
|
- aniObjName = string.Format(FORMAT_EFFECT_OBJ_NAME, itemCfg.subType, 2);
|
|
|
- TryRemoveObj(parentObj, aniObjName);
|
|
|
+ parentObj = sceneObj;
|
|
|
}
|
|
|
- //第三层
|
|
|
- if (!string.IsNullOrEmpty(itemCfg.resLayer3))
|
|
|
+ else
|
|
|
{
|
|
|
- spritObjName = string.Format(FORMAT_SPRITE_NAME, itemCfg.subType, 3);
|
|
|
- TryRemoveSprite(parentObj, spritObjName);
|
|
|
- aniObjName = string.Format(FORMAT_ANIMATION_NAME, itemCfg.subType, 3);
|
|
|
- TryRemoveObj(parentObj, aniObjName);
|
|
|
- aniObjName = string.Format(FORMAT_EFFECT_OBJ_NAME, itemCfg.subType, 3);
|
|
|
- TryRemoveObj(parentObj, aniObjName);
|
|
|
+ //角色
|
|
|
+ Transform role = sceneObj.transform.Find(ROLE_OBJ_NAME);
|
|
|
+ parentObj = role.gameObject;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- public static DressUpRemoveOperation RemoveItemAsync(int itemID, GameObject sceneObj, GameObject parentObj = null)
|
|
|
- {
|
|
|
- var operation = new DressUpRemoveOperation(itemID, sceneObj, parentObj);
|
|
|
+ var operation = new DressUpRemoveOperation(itemID, parentObj);
|
|
|
operation.Begin();
|
|
|
return operation;
|
|
|
}
|
|
@@ -178,7 +178,6 @@ namespace GFGGame
|
|
|
var extPng = "png";
|
|
|
string resPath = null;
|
|
|
string effectResPath = null;
|
|
|
- string objName;
|
|
|
bool showAni = !string.IsNullOrEmpty(actionRes);
|
|
|
string aniResPath = null;
|
|
|
if (showAni)
|
|
@@ -192,7 +191,6 @@ namespace GFGGame
|
|
|
if(showAni)
|
|
|
{
|
|
|
resPath = aniResPath;
|
|
|
- objName = BODY_ANIMATION_NAME;
|
|
|
//特效
|
|
|
effectResPath = ResPathUtil.GetDressUpEffectPath(actionRes, true);
|
|
|
if (!YooAssets.CheckResExist(effectResPath))
|
|
@@ -203,9 +201,8 @@ namespace GFGGame
|
|
|
else
|
|
|
{
|
|
|
resPath = ResPathUtil.GetDressUpPath(BODY_DEFAULT_RES_NAME, extPng);
|
|
|
- objName = BODY_SPRITE_NAME;
|
|
|
}
|
|
|
- if (GetGameObjExisted(parentObj, objName, resPath) != null || !YooAssets.CheckResExist(resPath))
|
|
|
+ if (!YooAssets.CheckResExist(resPath))
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
@@ -230,20 +227,16 @@ namespace GFGGame
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- string objName;
|
|
|
if (showAni)
|
|
|
{
|
|
|
resPath = aniResPath;
|
|
|
- objName = string.Format(DressUpUtil.FORMAT_ANIMATION_NAME, itemCfg.subType, layerId);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
resPath = ResPathUtil.GetDressUpPath(itemCfg, layerId);
|
|
|
- objName = string.Format(DressUpUtil.FORMAT_SPRITE_NAME, itemCfg.subType, layerId);
|
|
|
}
|
|
|
|
|
|
- var gameObj = DressUpUtil.GetGameObjExisted(parentObj, objName, resPath);
|
|
|
- if (gameObj != null || !YooAssets.CheckResExist(resPath))
|
|
|
+ if (!YooAssets.CheckResExist(resPath))
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
@@ -469,7 +462,7 @@ namespace GFGGame
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static void SetRenderersOrder(GameObject gameObj, int sortingOrder, bool isAdd = false)
|
|
|
+ public static void SetRenderersOrder(GameObject gameObj, int sortingOrder)
|
|
|
{
|
|
|
var meshRenderers = gameObj.transform.GetComponentsInChildren<MeshRenderer>();
|
|
|
for (int i = 0; i < meshRenderers.Length; i++)
|
|
@@ -477,14 +470,7 @@ namespace GFGGame
|
|
|
var renderer = meshRenderers[i].GetComponent<Renderer>();
|
|
|
if (renderer != null)
|
|
|
{
|
|
|
- if (isAdd)
|
|
|
- {
|
|
|
- renderer.sortingOrder = renderer.sortingOrder + sortingOrder;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- renderer.sortingOrder = sortingOrder;
|
|
|
- }
|
|
|
+ renderer.sortingOrder = sortingOrder;
|
|
|
}
|
|
|
}
|
|
|
ParticleSystem[] particles = gameObj.transform.GetComponentsInChildren<ParticleSystem>();
|
|
@@ -493,33 +479,13 @@ namespace GFGGame
|
|
|
var renderer = particles[i].GetComponent<Renderer>();
|
|
|
if (renderer != null)
|
|
|
{
|
|
|
- if (isAdd)
|
|
|
- {
|
|
|
- renderer.sortingOrder = renderer.sortingOrder + sortingOrder;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
-
|
|
|
- renderer.sortingOrder = sortingOrder;
|
|
|
- }
|
|
|
+ renderer.sortingOrder = sortingOrder;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- SetGoLayers(gameObj, 0);
|
|
|
}
|
|
|
|
|
|
|
|
|
- private static void SetGoLayers(GameObject gameObject, int layer)
|
|
|
- {
|
|
|
- if (gameObject == null || gameObject.layer == layer)
|
|
|
- return;
|
|
|
-
|
|
|
- var helperTransformList = gameObject.GetComponentsInChildren<Transform>(true);
|
|
|
- int cnt = helperTransformList.Length;
|
|
|
- for (int i = 0; i < cnt; i++)
|
|
|
- helperTransformList[i].gameObject.layer = layer;
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
}
|