浏览代码

UI界面上的换装对象优化

guodong 2 年之前
父节点
当前提交
add7ea29be

+ 9 - 4
GameClient/Assets/Game/HotUpdate/DressUp/DressUpUtil.cs

@@ -167,7 +167,7 @@ namespace GFGGame
 
             //清理旧的
             TryClearSpriteObj(parentObj, BODY_SPRITE_NAME);
-            TryRemoveObj(parentObj, BODY_ANIMATION_NAME);
+            var removeBodyAni = TryRemoveObj(parentObj, BODY_ANIMATION_NAME);
             TryRemoveObj(parentObj, BODY_EFFECT_OBJ_NAME);
 
             if (isAni)
@@ -177,7 +177,10 @@ namespace GFGGame
             else
             {
                 AddSpriteObj(res, "png", BODY_SPRITE_NAME, parentObj, 0, needSetMask); 
-                parentObj.transform.SetPositionAndRotation(new Vector3(), new Quaternion());
+                if(removeBodyAni)
+                {
+                    parentObj.transform.SetPositionAndRotation(new Vector3(), new Quaternion());
+                }
             }
             //特效
             if (!string.IsNullOrEmpty(effRes))
@@ -379,11 +382,11 @@ namespace GFGGame
             return gameObj;
         }
 
-        private static void TryRemoveObj(GameObject parentObj, string aniObjName)
+        private static bool TryRemoveObj(GameObject parentObj, string aniObjName)
         {
             if (parentObj == null)
             {
-                return;
+                return false;
             }
             Transform transform = parentObj.transform.Find(aniObjName);
             if (transform != null)
@@ -392,8 +395,10 @@ namespace GFGGame
                 if (gameObj != null)
                 {
                     GameObject.DestroyImmediate(gameObj);
+                    return true;
                 }
             }
+            return false;
         }
 
         public static GameObject CreateAnimationObj(string resPath)

+ 0 - 1
GameClient/Assets/Game/HotUpdate/Views/DressUp/DressUpFightView.cs

@@ -184,7 +184,6 @@ namespace GFGGame
             if (_sceneObject == null)
             {
                 _sceneObject = GameObject.Instantiate(_scenePrefab);
-                MyDressUpHelper.dressUpObj.TakeOffAll();
                 MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false);
                 MyDressUpHelper.dressUpObj.PutOnDefaultDressUpData();
             }