Bläddra i källkod

换装UI优化

guodong 1 år sedan
förälder
incheckning
7557f652c3

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

@@ -57,6 +57,7 @@ namespace GFGGame
             }
         }
 
+        private Action onUpdateAction;
 
         /// <summary>
         /// 
@@ -67,7 +68,7 @@ namespace GFGGame
         /// <param name="roleObj"></param>
         /// <param name="showBg"></param>
         /// <param name="resetData">是否重置装备数据</param>
-        public void setSceneObj(GameObject sceneObj, bool needSetMask = false, bool showSceneType = true, GameObject roleObj = null, bool showBg = true)
+        public void setSceneObj(GameObject sceneObj, bool needSetMask = false, bool showSceneType = true, GameObject roleObj = null, bool showBg = true, Action onUpdateAction  = null)
         {
             if (_sceneObj != null && _sceneObj != sceneObj)
             {
@@ -78,6 +79,7 @@ namespace GFGGame
             _showSceneType = showSceneType;
             _showBg = showBg;
             _roleObj = roleObj;
+            this.onUpdateAction = onUpdateAction;
             if (_dressUpData.IsNew)
             {
                 PutOnDefaultDressUpData();
@@ -105,6 +107,7 @@ namespace GFGGame
             {
                 t.Release();
             }
+            onUpdateAction = null;
         }
 
         private void ClearView()
@@ -705,6 +708,7 @@ namespace GFGGame
                         }
                         handler.Release();
                     }
+                    onUpdateAction?.Invoke();
                     //Debug.Log($"draw    {TimeHelper.ClientNow()}");
                 }
             }

+ 3 - 5
GameClient/Assets/Game/HotUpdate/DressUp/DressUpObjUI.cs

@@ -24,8 +24,7 @@ namespace GFGGame
             //这里每次都要实例化新的,复用会有bug
             sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath(this.prefabName));
             sceneObject.transform.localScale = new Vector3(scale, scale, scale);
-            dressUpObj.setSceneObj(sceneObject, needSetMask, showSceneType, roleObj, showBg);
-            Timers.inst.AddUpdate(OnUpdate);
+            dressUpObj.setSceneObj(sceneObject, needSetMask, showSceneType, roleObj, showBg, OnUpdate);
         }
 
         public void UpdateWrapper(GGraph holder)
@@ -59,18 +58,17 @@ namespace GFGGame
             }
         }
 
-        private void OnUpdate(object o)
+        private void OnUpdate()
         {
             if(sceneObject == null)
             {
-                Timers.inst.Remove(OnUpdate);
                 return;
             }
             if(wrapper != null)
             {
                 wrapper.wrapTarget = sceneObject;
+                //wrapper.CacheRenderers();
             }
-            //wrapper.CacheRenderers();
         }
     }
 }