Browse Source

部件动画特效处理

guodong 2 years ago
parent
commit
488a9d58b7

+ 6 - 5
GameClient/Assets/Game/HotUpdate/DressUp/DressUpUtil.cs

@@ -186,7 +186,7 @@ namespace GFGGame
             //特效
             if (!string.IsNullOrEmpty(effRes))
             {
-                TryAddEffectObj(effRes, BODY_EFFECT_OBJ_NAME, parentObj, 0);
+                TryAddEffectObj(effRes, BODY_EFFECT_OBJ_NAME, parentObj, 0, false);
             }
         }
 
@@ -237,9 +237,10 @@ namespace GFGGame
             //这里需要先添加静态图,防止加载动画有延迟,出现光头
             GameObject spriteObj = AddSpriteObj(res, ext, spritObjName, parentObj, sortingOrder, needSetMask);
 
+            GameObject aniObj = null;
             if (showAni)
             {
-                var aniObj = AddAnimationObj(res, aniObjName, parentObj, sortingOrder);
+                aniObj = AddAnimationObj(res, aniObjName, parentObj, sortingOrder);
                 if (aniObj != null && spriteObj != null)
                 {
                     Timers.inst.Add(0.03f, 1, (obj) =>
@@ -269,7 +270,7 @@ namespace GFGGame
 
             aniObjName = string.Format(FORMAT_EFFECT_OBJ_NAME, itemCfg.subType, layerId);
             TryRemoveObj(parentObj, aniObjName);
-            TryAddEffectObj(res, aniObjName, parentObj, sortingOrder);
+            TryAddEffectObj(res, aniObjName, parentObj, sortingOrder, aniObj != null);
         }
 
         private static GameObject AddSpriteObj(string res, string ext, string objName, GameObject parentObj, int sortingOrder, bool needSetMask)
@@ -423,9 +424,9 @@ namespace GFGGame
             return gameObj;
         }
 
-        private static void TryAddEffectObj(string res, string objName, GameObject parentObj, int sortingOrder)
+        private static void TryAddEffectObj(string res, string objName, GameObject parentObj, int sortingOrder, bool toAni)
         {
-            var resPath = ResPathUtil.GetDressUpEffectPath(res);
+            var resPath = ResPathUtil.GetDressUpEffectPath(res, toAni);
             if (!VEngine.Versions.Contains(resPath))
             {
                 return;

+ 5 - 1
GameClient/Assets/Game/HotUpdate/Utils/ResPathUtil.cs

@@ -111,8 +111,12 @@ namespace GFGGame
         {
             return $"{ANIMATION_DIR_PATH}/DressUp/{res}/{res}.{extName}";
         }
-        public static string GetDressUpEffectPath(string res, string extName = "prefab")
+        public static string GetDressUpEffectPath(string res, bool toAni = false, string extName = "prefab")
         {
+            if(toAni)
+            {
+                return $"{EFFECT_DIR_PATH}/DressUpAni/{res}/{res}.{extName}";
+            }
             return $"{EFFECT_DIR_PATH}/DressUp/{res}/{res}.{extName}";
         }
         public static string GetViewEffectPath(string uiName, string resName, string extName = "prefab")