Browse Source

Merge branch 'master' of http://10.108.64.190:3000/gfg/client

zhaoyang 2 years ago
parent
commit
add2851759

+ 1 - 1
GameClient/Assets/Game/HotUpdate/DressUp/DressUpObj.cs

@@ -592,7 +592,7 @@ namespace GFGGame
                 SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_dressUpData.actionId);
                 var hasAniRes = ResPathUtil.CheckDressUpAnimationResExist(suitCfg.aniRes);
                 var actionRes = hasAniRes ? suitCfg.aniRes : null;
-                DressUpUtil.UpdateBody(actionRes, _sceneObj, _needSetMask, _roleObj);
+                DressUpUtil.UpdateBody(actionRes, _sceneObj, false, _roleObj);
             }
             else
             {

+ 19 - 0
GameClient/Assets/Game/HotUpdate/DressUp/DressUpPart.cs

@@ -0,0 +1,19 @@
+using FairyGUI;
+using UnityEngine;
+
+namespace GFGGame
+{
+
+    public class DressUpPart : MonoBehaviour
+    {
+        public TimerCallback OnTimer;
+
+        private void OnDestroy()
+        {
+            if(OnTimer != null)
+            {
+                Timers.inst.Remove(OnTimer);
+            }
+        }
+    }
+}

+ 11 - 0
GameClient/Assets/Game/HotUpdate/DressUp/DressUpPart.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 307d9ed9723f6ad4bba9ba08cfbfea5b
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 29 - 19
GameClient/Assets/Game/HotUpdate/DressUp/DressUpUtil.cs

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