Forráskód Böngészése

换装支持异步加载

guodong 1 éve
szülő
commit
11acf470c6

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Assets/PrefabManager.cs

@@ -36,7 +36,7 @@ namespace GFGGame
                 _entitySpawner.CreateGameObjectPoolSync(resPath, false, 0, 1, 60);
             }
 
-            var handle = _entitySpawner.SpawnAsync(resPath);
+            SpawnHandle handle = _entitySpawner.SpawnAsync(resPath);
             await handle.Task;
             AssetReleaserHelper.AddReleaserToSpawnObj(handle.GameObj, resPath, handle);
             return handle.GameObj;

+ 14 - 3
GameClient/Assets/Game/HotUpdate/Data/PhotographSceneManager.cs

@@ -59,7 +59,7 @@ namespace GFGGame
         }
 
         //拍照场景添加单个道具
-        public void AddItemToScene(GameObject sceneObj, GameObject parentGameObj, int itemId, int resLayer)
+        public async void AddItemToScene(GameObject sceneObj, GameObject parentGameObj, int itemId, int resLayer)
         {
             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
             parentGameObj.transform.SetParent(sceneObj.transform.Find("Scene"), false);
@@ -71,14 +71,25 @@ namespace GFGGame
             string res = value == "n" ? itemCfg.res : string.Format("{0}_{1}", itemCfg.res, value);
 
             string resPath = ResPathUtil.GetDressUpAnimationPath(res);
+            var handler = DressUpUtil.AddItemAsync(itemId, sceneObj, false, true, parentGameObj, resLayer);
+            if(handler != null)
+            {
+                foreach(var t in handler)
+                {
+                    await t.Task;
+                }
+                foreach (var t in handler)
+                {
+                    t.UpdateView();
+                    t.Release();
+                }
+            }
             if (YooAssets.CheckResExist(resPath))
             {
-                DressUpUtil.AddItem(itemId, sceneObj, false, true, parentGameObj, resLayer);
                 parentGameObj.transform.localPosition = Vector3.zero;
             }
             else
             {
-                DressUpUtil.AddItem(itemId, sceneObj, false, false, parentGameObj, resLayer);
                 GameObject gameObject = parentGameObj.transform.GetChild(0).gameObject;
                 SetBoxCollider2DToGameObject(gameObject);
             }

+ 0 - 56
GameClient/Assets/Game/HotUpdate/DressUp/DressUpLayerHandler.cs

@@ -1,56 +0,0 @@
-using FairyGUI;
-using UnityEngine;
-
-namespace GFGGame
-{
-    public class DressUpLayerHandler : AsyncOperationBase
-    {
-        private ItemCfg itemCfg;
-        private bool showAni;
-        private int layerId;
-
-        public DressUpLayerHandler(ItemCfg itemCfg, GameObject parentObj, int layerId, bool needSetMask, bool showAni = true)
-        {
-            this.itemCfg = itemCfg;
-            this.showAni = showAni;
-            this.layerId = layerId;
-        }
-
-
-        public void UpdateView()
-        {
-
-        }
-
-        internal override void Start()
-        {
-            
-        }
-
-        internal override void Update()
-        {
-            
-        }
-
-
-        private void CheckRes()
-        {
-
-            ItemTypeCfg typeCfg = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType);
-
-            string res = ResPathUtil.GetDressUpItemLayerRes(itemCfg, layerId);
-            int sortingOrder = typeCfg.defaultLayer;
-            if (layerId == 2)
-            {
-                sortingOrder = typeCfg.specialLayer;
-            }
-            else if (layerId == 3)
-            {
-                sortingOrder = typeCfg.thirdlLayer;
-            }
-
-
-        }
-
-    }
-}

+ 283 - 0
GameClient/Assets/Game/HotUpdate/DressUp/DressUpLayerOperation.cs

@@ -0,0 +1,283 @@
+using ET;
+using System.Collections.Generic;
+using UnityEngine;
+using YooAsset;
+
+namespace GFGGame
+{
+    public class DressUpLayerOperation : DressUpOperationBase
+    {
+        private enum EAction
+        {
+            Layer,
+            Body,
+            Head
+        }
+        public const int PRE_RENDER_FRAME = 1;
+
+        private ItemCfg itemCfg;
+        private GameObject parentObj;
+        private int layerId;
+        private bool needSetMask;
+        private bool showAni;
+        private string resPath;
+        private string effectResPath;
+
+        private int preRendering;
+        private ResourceDownloaderOperation downloaderOperation;
+        private EAction actionType;
+
+        private List<GameObject> preloadList = new List<GameObject>();
+
+        public DressUpLayerOperation(GameObject parentObj, bool needSetMask, bool showAni, string resPath, string effectResPath)
+        {
+            this.parentObj = parentObj;
+            this.needSetMask = needSetMask;
+            this.resPath = resPath;
+            this.effectResPath = effectResPath;
+            this.showAni = showAni;
+            preRendering = 0;
+        }
+
+        public void InitLayer(ItemCfg itemCfg, int layerId)
+        {
+            this.itemCfg = itemCfg;
+            this.layerId = layerId;
+            actionType = EAction.Layer;
+        }
+
+        public void InitBody()
+        {
+            actionType = EAction.Body;
+        }
+
+        public void InitHead()
+        {
+            actionType = EAction.Head;
+        }
+
+        /// <summary>
+        /// 取消下载
+        /// </summary>
+        public void Cancel()
+        {
+            if (_steps != EDressUpSteps.Done)
+            {
+                if (downloaderOperation != null)
+                {
+                    downloaderOperation.CancelDownload();
+                }
+                _steps = EDressUpSteps.Done;
+                Status = EOperationStatus.Failed;
+                Error = "User cancel.";
+            }
+        }
+
+        internal override void UpdateView()
+        {
+            ViewManager.Hide<ModalStatusView>();
+            foreach (var t in preloadList)
+            {
+                Live2dAnimationManager.Instance.FinishPreDrawed(t);
+            }
+            preloadList.Clear();
+            preloadList = null;
+
+            switch (actionType)
+            {
+                case EAction.Layer:
+                    UpdateLayer();
+                    break;
+                case EAction.Body:
+                    UpdateBody();
+                    break;
+                case EAction.Head:
+                    UpdateHead();
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        internal override void Release()
+        {
+            downloaderOperation = null;
+            this.itemCfg = null;
+            this.parentObj = null;
+            preloadList?.Clear();
+            preloadList = null;
+        }
+
+        internal override void Start()
+        {
+            _steps = EDressUpSteps.Check;
+            Update();
+        }
+
+        internal override void Update()
+        {
+            if (_steps == EDressUpSteps.None || _steps == EDressUpSteps.Done)
+                return;
+            if (_steps == EDressUpSteps.Check)
+            {
+                CheckLoadRes();
+            }
+            if(_steps == EDressUpSteps.Loading)
+            {
+                Progress = downloaderOperation.Progress;
+                if(downloaderOperation.IsDone)
+                {
+                    if (downloaderOperation.Status == EOperationStatus.Succeed)
+                    {
+                        CheckPreDraw();
+                    }
+                    else
+                    {
+                        _steps = EDressUpSteps.Done;
+                        Status = EOperationStatus.Failed;
+                    }
+                }
+            }
+            if(_steps == EDressUpSteps.PreDrawing)
+            {
+                Debug.Log($"preRendering {preRendering}    {resPath} {TimeHelper.ClientNow()}");
+                if(preRendering <= 0)
+                {
+                    _steps = EDressUpSteps.Done;
+                    Status = EOperationStatus.Succeed;
+                }
+                preRendering--;
+            }
+        }
+
+        private void CheckLoadRes()
+        {
+            List<string> locations = new List<string>();
+            if(!string.IsNullOrEmpty(resPath))
+            {
+                //需加载
+                locations.Add(this.resPath);
+            }
+            if(!string.IsNullOrEmpty(effectResPath))
+            {
+                //需加载
+                locations.Add(effectResPath);
+            }
+            if(locations.Count == 0)
+            {
+                _steps = EDressUpSteps.Done;
+                Status = EOperationStatus.Succeed;
+                return;
+            }
+
+            downloaderOperation = YooAssets.CreateBundleDownloader(locations.ToArray(), 3, 3);
+            if(downloaderOperation.TotalDownloadCount == 0)
+            {
+                //文件已在本地,不需要下载
+                CheckPreDraw();
+                return;
+            }
+            ViewManager.Show<ModalStatusView>("加载中...");
+            //下载
+            _steps = EDressUpSteps.Loading;
+            downloaderOperation.BeginDownload();
+        }
+
+        private void CheckPreDraw()
+        {
+            if(!string.IsNullOrEmpty(resPath))
+            {
+                if (showAni)
+                {
+                    _steps = EDressUpSteps.PreDrawing;
+                    //设置预渲染帧数
+                    preRendering = PRE_RENDER_FRAME;
+                    //预渲染
+                    var t = Live2dAnimationManager.Instance.PreDraw(resPath);
+                    preloadList.Add(t);
+                    Debug.Log($"PreDraw    {resPath} {TimeHelper.ClientNow()}");
+                    return;
+                }
+            }
+            _steps = EDressUpSteps.Done;
+            Status = EOperationStatus.Succeed;
+        }
+
+        private void UpdateLayer()
+        {
+            //清理旧的
+            var spritObjName = string.Format(DressUpUtil.FORMAT_SPRITE_NAME, itemCfg.subType, layerId);
+            DressUpUtil.TryRemoveObj(parentObj, spritObjName);
+            var aniObjName = string.Format(DressUpUtil.FORMAT_ANIMATION_NAME, itemCfg.subType, layerId);
+            DressUpUtil.TryRemoveObj(parentObj, aniObjName);
+            string effectObjName = string.Format(DressUpUtil.FORMAT_EFFECT_OBJ_NAME, itemCfg.subType, layerId);
+            DressUpUtil.TryRemoveObj(parentObj, effectObjName);
+            //添加新的
+            int sortingOrder = ItemTypeCfgArray.Instance.GetSortingOrder(itemCfg.subType, layerId);
+            if (this.showAni)
+            {
+                DressUpUtil.AddAnimationObj(resPath, aniObjName, parentObj, sortingOrder);
+            }
+            else
+            {
+                string ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType);
+                DressUpUtil.AddSpriteObj(resPath, spritObjName, parentObj, sortingOrder, needSetMask);
+            }
+            if (!string.IsNullOrEmpty(effectResPath))
+            {
+                DressUpUtil.TryAddEffectObj(effectResPath, effectObjName, parentObj, sortingOrder);
+            }
+        }
+
+        private void UpdateBody()
+        {
+            var spritObjName = DressUpUtil.BODY_SPRITE_NAME;
+            var aniObjName = DressUpUtil.BODY_ANIMATION_NAME;
+            var effectObjName = DressUpUtil.BODY_EFFECT_OBJ_NAME;
+            int sortingOrder = 0;
+            var removeBodyAni = DressUpUtil.TryRemoveObj(parentObj, aniObjName);
+            DressUpUtil.TryRemoveObj(parentObj, effectObjName);
+            DressUpUtil.TryRemoveObj(parentObj, spritObjName);
+            if (this.showAni)
+            {
+                DressUpUtil.AddAnimationObj(this.resPath, aniObjName, parentObj, sortingOrder);
+            }
+            else
+            {
+                DressUpUtil.AddSpriteObj(this.resPath, spritObjName, parentObj, sortingOrder, needSetMask);
+                if (removeBodyAni)
+                {
+                    parentObj.transform.SetPositionAndRotation(new Vector3(), new Quaternion());
+                }
+            }
+            if (!string.IsNullOrEmpty(effectResPath))
+            {
+                DressUpUtil.TryAddEffectObj(effectResPath, effectObjName, parentObj, sortingOrder);
+            }
+        }
+
+        private void UpdateHead()
+        {
+            var spritObjName = DressUpUtil.HEAD_SPRITE_NAME; 
+            int sortingOrder = 1;
+            Transform transform_t = parentObj.transform.Find(spritObjName);
+            if (!string.IsNullOrEmpty(this.resPath))
+            {
+                if (transform_t != null)
+                {
+                    transform_t.gameObject.SetActive(true);
+                    return;
+                }
+                DressUpUtil.AddSpriteObj(resPath, spritObjName, parentObj, sortingOrder, needSetMask);
+            }
+            else
+            {
+                if (transform_t == null)
+                {
+                    return;
+                }
+                transform_t.gameObject.SetActive(false);
+            }
+        }
+    }
+}

+ 0 - 0
GameClient/Assets/Game/HotUpdate/DressUp/DressUpLayerHandler.cs.meta → GameClient/Assets/Game/HotUpdate/DressUp/DressUpLayerOperation.cs.meta


+ 65 - 17
GameClient/Assets/Game/HotUpdate/DressUp/DressUpObj.cs

@@ -168,7 +168,8 @@ namespace GFGGame
                     return;
                 }
                 _dressUpData.bgId = itemId;
-                DressUpUtil.AddItem(_dressUpData.bgId, _sceneObj, _needSetMask, true, _roleObj);
+                List<DressUpLayerOperation> handlers = DressUpUtil.AddItemAsync(_dressUpData.bgId, _sceneObj, _needSetMask, true, _roleObj);
+                TryAddHandlers(handlers);
             }
             else
             {
@@ -301,8 +302,7 @@ namespace GFGGame
                     if (notInAction)
                     {
                         //更新成图片模式
-                        AddOrRemove(itemId, false, DressUpOption.Remove);
-                        AddOrRemove(itemId, false, DressUpOption.Add);
+                        Update(itemId);
                     }
                 }
             }
@@ -382,6 +382,7 @@ namespace GFGGame
         private bool _showSceneType = true;
         private bool _showBg = true;
         private DressUpData _dressUpData = new DressUpData();
+        private List<DressUpOperationBase> handlers = new List<DressUpOperationBase>();
         //穿上一个动作
         private void PutOnAction(int actionId)
         {
@@ -394,12 +395,15 @@ namespace GFGGame
                     if (!DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemId))
                     {
                         //场景类型不受动作影响并且本来就有动画,对非场景类型处理
-                        AddOrRemove(itemId, false, DressUpOption.Remove);
                         bool notInAction = SuitCfgArray.Instance.CheckItemNotInAction(itemId);
                         if (notInAction)
                         {
                             //更新成动画模式
-                            AddOrRemove(itemId, false, DressUpOption.Add);
+                            Update(itemId);
+                        }
+                        else
+                        {
+                            AddOrRemove(itemId, false, DressUpOption.Remove);
                         }
                     }
                 }
@@ -437,12 +441,17 @@ namespace GFGGame
             if (!_dressUpData.itemList.Contains(itemId))
             {
                 _dressUpData.itemList.Add(itemId);
-                bool showAni = IsAction || DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemId);
-                DressUpUtil.AddItem(itemId, _sceneObj, _needSetMask, showAni, _roleObj);
-                // FightDataManager.Instance.score += ItemDataManager.GetItemAdditionScore(itemId, InstanceZonesDataManager.currentScoreType, InstanceZonesDataManager.currentFightTags);
+                Update(itemId);
             }
         }
 
+        private void Update(int itemId)
+        {
+            bool showAni = IsAction || DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemId);
+            var handlers = DressUpUtil.AddItemAsync(itemId, _sceneObj, _needSetMask, showAni, _roleObj);
+            TryAddHandlers(handlers);
+        }
+
         private void Remove(int itemId)
         {
             if (_dressUpData.itemList == null)
@@ -452,8 +461,8 @@ namespace GFGGame
             if (_dressUpData.itemList.Contains(itemId))
             {
                 _dressUpData.itemList.Remove(itemId);
-                DressUpUtil.RemoveItem(itemId, _sceneObj, _roleObj);
-                // FightDataManager.Instance.score -= ItemDataManager.GetItemAdditionScore(itemId, InstanceZonesDataManager.currentScoreType, InstanceZonesDataManager.currentFightTags);
+                var handler = DressUpUtil.RemoveItemAsync(itemId, _sceneObj, _roleObj);
+                TryAddHandler(handler);
             }
         }
 
@@ -507,7 +516,8 @@ namespace GFGGame
                     if (!DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemID))
                     {
                         //非场景类型重穿
-                        AddOrRemove(itemID, false, DressUpOption.Remove);
+                        Update(itemID);
+                        targetItemList.Remove(itemID);
                     }
                 }
             }
@@ -628,29 +638,67 @@ namespace GFGGame
                 }
             }
             CheckCurDressIsSuit();
-            DressUpUtil.UpdateHead(!hasZhuangRong, _sceneObj, _needSetMask, _roleObj);
+            var handler = DressUpUtil.UpdateHeadAsync(!hasZhuangRong, _sceneObj, _needSetMask, _roleObj);
+            TryAddHandler(handler);
             UpdateBodyView();
         }
 
         //更新整个身体
         private void UpdateBodyView()
         {
+            string actionRes = null;
             if (IsAction)
             {
                 SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_dressUpData.actionId);
                 var hasAniRes = ResPathUtil.CheckDressUpAnimationResExist(suitCfg.aniRes);
-                var actionRes = hasAniRes ? suitCfg.aniRes : null;
-                DressUpUtil.UpdateBody(actionRes, _sceneObj, false, _roleObj);
+                actionRes = hasAniRes ? suitCfg.aniRes : null;
             }
-            else
+            var handler = DressUpUtil.UpdateBodyAsync(actionRes, _sceneObj, _needSetMask, _roleObj);
+            TryAddHandler(handler);
+        }
+
+        private void OnUpdate(object param = null)
+        {
+            if(handlers != null && handlers.Count > 0)
             {
-                DressUpUtil.UpdateBody(null, _sceneObj, _needSetMask, _roleObj);
+                bool draw = true;
+                foreach(var handler in handlers)
+                {
+                    if(!handler.IsDone)
+                    {
+                        draw = false;
+                    }
+                }
+                if(draw)
+                {
+                    var t = handlers.ToArray(); 
+                    handlers.Clear();
+                    foreach (var handler in t)
+                    {
+                        handler.UpdateView();
+                        handler.Release();
+                    }
+                    //Debug.Log($"draw    {TimeHelper.ClientNow()}");
+                }
             }
         }
 
-        private void OnUpdate(object param)
+        private void TryAddHandlers(List<DressUpLayerOperation> handlers)
         {
+            if (handlers != null)
+            {
+                this.handlers.AddRange(handlers);
+                //OnUpdate();
+            }
+        }
 
+        private void TryAddHandler(DressUpOperationBase handler)
+        {
+            if (handler != null)
+            {
+                this.handlers.Add(handler);
+                //OnUpdate();
+            }
         }
 
         #endregion

+ 29 - 0
GameClient/Assets/Game/HotUpdate/DressUp/DressUpOperationBase.cs

@@ -0,0 +1,29 @@
+using System;
+
+namespace GFGGame
+{
+    public abstract class DressUpOperationBase : AsyncOperationBase
+    {
+        protected enum EDressUpSteps
+        {
+            None,
+            Check,
+            Loading,
+            PreDrawing,
+            PreDrawingWaiting,
+            Done,
+        }
+        protected EDressUpSteps _steps = EDressUpSteps.None;
+        public void Begin()
+        {
+            if (_steps == EDressUpSteps.None)
+            {
+                OperationSystem.StartOperation(this);
+            }
+        }
+
+        internal abstract void UpdateView();
+
+        internal abstract void Release();
+    }
+}

+ 1 - 1
GameClient/Assets/Game/HotUpdate/OperationSystem/EOperationStatus.cs.meta → GameClient/Assets/Game/HotUpdate/DressUp/DressUpOperationBase.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: f9ffba02477bcbf4086f6308d706e281
+guid: 6422f8fbdf55e3f42a4cd5cba408413c
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 40 - 0
GameClient/Assets/Game/HotUpdate/DressUp/DressUpRemoveOperation.cs

@@ -0,0 +1,40 @@
+using UnityEngine;
+using YooAsset;
+
+namespace GFGGame
+{
+    public class DressUpRemoveOperation : DressUpOperationBase
+    {
+        private int itemID;
+        private GameObject sceneObj;
+        private GameObject parentObj;
+
+        public DressUpRemoveOperation(int itemID, GameObject sceneObj, GameObject parentObj)
+        {
+            this.itemID = itemID;
+            this.sceneObj = sceneObj;
+            this.parentObj = parentObj;
+        }
+
+        internal override void Release()
+        {
+            this.sceneObj = null;
+            this.parentObj = null;
+        }
+
+        internal override void Start()
+        {
+            Status = EOperationStatus.Succeed;
+        }
+
+        internal override void Update()
+        {
+            
+        }
+
+        internal override void UpdateView()
+        {
+            DressUpUtil.RemoveItem(this.itemID, this.sceneObj, this.parentObj);
+        }
+    }
+}

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

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

+ 326 - 146
GameClient/Assets/Game/HotUpdate/DressUp/DressUpUtil.cs

@@ -4,26 +4,88 @@ using System.IO;
 using FairyGUI;
 using UnityEngine.Rendering;
 using YooAsset;
+using System.Collections.Generic;
 
 namespace GFGGame
 {
     public class DressUpUtil
     {
-        private const string HEAD_DEFAULT_RES_NAME = "head";
-        private const string BODY_DEFAULT_RES_NAME = "body";
-        private const string ROLE_OBJ_NAME = "Role";
-        private const string HEAD_SPRITE_NAME = "Head";
-        private const string BODY_SPRITE_NAME = "Body";
+        public const string HEAD_DEFAULT_RES_NAME = "head";
+        public const string BODY_DEFAULT_RES_NAME = "body";
+        public const string ROLE_OBJ_NAME = "Role";
+        public const string HEAD_SPRITE_NAME = "Head";
+        public const string BODY_SPRITE_NAME = "Body";
         public const string BODY_ANIMATION_NAME = "Body_a";
-        private const string BODY_EFFECT_OBJ_NAME = "Body_eff";
+        public const string BODY_EFFECT_OBJ_NAME = "Body_eff";
         public const string FORMAT_SPRITE_NAME = "T{0}_s{1}";
-        private const string FORMAT_ANIMATION_NAME = "T{0}_a{1}";
-        private const string FORMAT_EFFECT_OBJ_NAME = "T{0}_e{1}";
+        public const string FORMAT_ANIMATION_NAME = "T{0}_a{1}";
+        public const string FORMAT_EFFECT_OBJ_NAME = "T{0}_e{1}";
 
-        public static void AddItem(int itemID, GameObject sceneObj, bool needSetMask = false, bool showAni = true, GameObject parentObj = null, int resLayer = 0)
+        //public static void AddItem(int itemID, GameObject sceneObj, bool needSetMask = false, bool showAni = true, GameObject parentObj = null, int resLayer = 0)
+        //{
+        //    ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemID);
+        //    if (itemCfg == null) return;
+
+        //    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;
+        //        }
+        //    }
+        //    showAni = showAni || itemCfg.subType == ConstDressUpItemType.ZHUANG_RONG;
+        //    if (resLayer > 0)
+        //    {
+        //        string layerName = "";
+        //        switch (resLayer)
+        //        {
+        //            case 1:
+        //                layerName = itemCfg.resLayer1;
+        //                break;
+        //            case 2:
+        //                layerName = itemCfg.resLayer2;
+        //                break;
+        //            case 3:
+        //                layerName = itemCfg.resLayer3;
+        //                break;
+        //        }
+        //        if (!string.IsNullOrEmpty(layerName))
+        //        {
+        //            UpdateLayerRes(itemCfg, parentObj, resLayer, needSetMask, showAni);
+        //        }
+        //    }
+        //    else
+        //    {
+        //        //普通层
+        //        if (!string.IsNullOrEmpty(itemCfg.resLayer1))
+        //        {
+        //            UpdateLayerRes(itemCfg, parentObj, 1, needSetMask, showAni);
+        //        }
+        //        //第二层
+        //        if (!string.IsNullOrEmpty(itemCfg.resLayer2))
+        //        {
+
+        //            UpdateLayerRes(itemCfg, parentObj, 2, needSetMask, showAni);
+        //        }
+        //        //第三层
+        //        if (!string.IsNullOrEmpty(itemCfg.resLayer3))
+        //        {
+
+        //            UpdateLayerRes(itemCfg, parentObj, 3, needSetMask, showAni);
+        //        }
+        //    }
+        //}
+
+        public static List<DressUpLayerOperation> AddItemAsync(int itemID, GameObject sceneObj, bool needSetMask = false, bool showAni = true, GameObject parentObj = null, int resLayer = 0)
         {
             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemID);
-            if (itemCfg == null) return;
+            if (itemCfg == null) return null;
 
             if (parentObj == null)
             {
@@ -39,6 +101,8 @@ namespace GFGGame
                 }
             }
             showAni = showAni || itemCfg.subType == ConstDressUpItemType.ZHUANG_RONG;
+            List<DressUpLayerOperation> handlers = new List<DressUpLayerOperation>();
+            DressUpLayerOperation handler;
             if (resLayer > 0)
             {
                 string layerName = "";
@@ -56,7 +120,8 @@ namespace GFGGame
                 }
                 if (!string.IsNullOrEmpty(layerName))
                 {
-                    updateLayerRes(itemCfg, parentObj, resLayer, needSetMask, showAni);
+                    handler = UpdateLayerResAsync(itemCfg, parentObj, resLayer, needSetMask, showAni);
+                    if (handler != null) handlers.Add(handler);
                 }
             }
             else
@@ -64,21 +129,29 @@ namespace GFGGame
                 //普通层
                 if (!string.IsNullOrEmpty(itemCfg.resLayer1))
                 {
-                    updateLayerRes(itemCfg, parentObj, 1, needSetMask, showAni);
+                    handler = UpdateLayerResAsync(itemCfg, parentObj, 1, needSetMask, showAni);
+                    if (handler != null) handlers.Add(handler);
                 }
                 //第二层
                 if (!string.IsNullOrEmpty(itemCfg.resLayer2))
                 {
 
-                    updateLayerRes(itemCfg, parentObj, 2, needSetMask, showAni);
+                    handler = UpdateLayerResAsync(itemCfg, parentObj, 2, needSetMask, showAni);
+                    if (handler != null) handlers.Add(handler);
                 }
                 //第三层
                 if (!string.IsNullOrEmpty(itemCfg.resLayer3))
                 {
 
-                    updateLayerRes(itemCfg, parentObj, 3, needSetMask, showAni);
+                    handler = UpdateLayerResAsync(itemCfg, parentObj, 3, needSetMask, showAni);
+                    if (handler != null) handlers.Add(handler);
                 }
             }
+            if(handlers.Count > 0)
+            {
+                return handlers;
+            }
+            return null;
         }
 
         public static void RemoveItem(int itemID, GameObject sceneObj, GameObject parentObj = null)
@@ -134,159 +207,268 @@ namespace GFGGame
             }
         }
 
-        public static void UpdateHead(bool show, GameObject sceneObj, bool needSetMask = false, GameObject parentObj = null)
+        public static DressUpRemoveOperation RemoveItemAsync(int itemID, GameObject sceneObj, GameObject parentObj = null)
+        {
+            var operation = new DressUpRemoveOperation(itemID, sceneObj, parentObj);
+            operation.Begin();
+            return operation;
+        }
+
+        //public static void UpdateHead(bool show, GameObject sceneObj, bool needSetMask = false, GameObject parentObj = null)
+        //{
+        //    var roleTf = sceneObj.transform.Find(ROLE_OBJ_NAME);
+        //    parentObj = parentObj == null ? roleTf.gameObject : parentObj;
+        //    string resPath = ResPathUtil.GetDressUpPath(HEAD_DEFAULT_RES_NAME);
+
+        //    Transform transform_t = parentObj.transform.Find(HEAD_SPRITE_NAME);
+        //    if (show)
+        //    {
+        //        if (transform_t != null)
+        //        {
+        //            transform_t.gameObject.SetActive(true);
+        //            return;
+        //        }
+        //        AddSpriteObj(resPath, HEAD_SPRITE_NAME, parentObj, 1, needSetMask);
+        //    }
+        //    else
+        //    {
+        //        if (transform_t == null)
+        //        {
+        //            return;
+        //        }
+        //        transform_t.gameObject.SetActive(false);
+        //    }
+        //}
+
+        public static DressUpLayerOperation UpdateHeadAsync(bool show, GameObject sceneObj, bool needSetMask = false, GameObject parentObj = null)
         {
             var roleTf = sceneObj.transform.Find(ROLE_OBJ_NAME);
             parentObj = parentObj == null ? roleTf.gameObject : parentObj;
-            string resPath = ResPathUtil.GetDressUpPath(HEAD_DEFAULT_RES_NAME);
-
-            Transform transform_t = parentObj.transform.Find(HEAD_SPRITE_NAME);
-            if (show)
-            {
-                if (transform_t != null)
-                {
-                    transform_t.gameObject.SetActive(true);
-                    return;
-                }
-                AddSpriteObj(resPath, "png", HEAD_SPRITE_NAME, parentObj, 1, needSetMask);
-            }
-            else
+            string res = null;
+            string resPath = null;
+            if(show)
             {
-                if (transform_t == null)
-                {
-                    return;
-                }
-                transform_t.gameObject.SetActive(false);
+                res = HEAD_DEFAULT_RES_NAME;
+                resPath = ResPathUtil.GetDressUpPath(res);
             }
+            DressUpLayerOperation handler = new DressUpLayerOperation(parentObj, needSetMask, false, resPath, null);
+            handler.InitHead();
+            handler.Begin();
+            return handler;
         }
 
-        public static void UpdateBody(string actionRes, GameObject sceneObj, bool needSetMask = false, GameObject parentObj = null)
+        //public static void UpdateBody(string actionRes, GameObject sceneObj, bool needSetMask = false, GameObject parentObj = null)
+        //{
+        //    //角色
+        //    var roleTf = sceneObj.transform.Find(ROLE_OBJ_NAME);
+        //    parentObj = parentObj == null ? roleTf.gameObject : parentObj;
+
+        //    var extPng = "png";
+        //    if (!string.IsNullOrEmpty(actionRes))
+        //    {
+        //        string resPath = ResPathUtil.GetDressUpAnimationPath(actionRes);
+        //        if (GetGameObjExisted(parentObj, BODY_ANIMATION_NAME, resPath) != null)
+        //        {
+        //            return;
+        //        }
+        //    }
+        //    else
+        //    {
+        //        string resPath = ResPathUtil.GetDressUpPath(BODY_DEFAULT_RES_NAME, extPng);
+        //        if (GetGameObjExisted(parentObj, BODY_SPRITE_NAME, resPath) != null)
+        //        {
+        //            return;
+        //        }
+        //    }
+
+        //    var removeBodyAni = TryRemoveObj(parentObj, BODY_ANIMATION_NAME);
+        //    TryRemoveObj(parentObj, BODY_EFFECT_OBJ_NAME);
+        //    TryRemoveObj(parentObj, BODY_SPRITE_NAME);
+        //    if (!string.IsNullOrEmpty(actionRes))
+        //    {
+
+        //        string aniResPath = ResPathUtil.GetDressUpAnimationPath(actionRes);
+        //        var addAniObj = AddAnimationObj(aniResPath, BODY_ANIMATION_NAME, parentObj, 0);
+        //        //特效
+        //        var resPath = ResPathUtil.GetDressUpEffectPath(actionRes, addAniObj != null);
+        //        TryAddEffectObj(resPath, BODY_EFFECT_OBJ_NAME, parentObj, 0);
+        //    }
+        //    else
+        //    {
+        //        AddSpriteObj(ResPathUtil.GetDressUpPath(BODY_DEFAULT_RES_NAME), BODY_SPRITE_NAME, parentObj, 0, needSetMask);
+        //        if (removeBodyAni)
+        //        {
+        //            parentObj.transform.SetPositionAndRotation(new Vector3(), new Quaternion());
+        //        }
+        //    }
+        //}
+
+        public static DressUpLayerOperation UpdateBodyAsync(string actionRes, GameObject sceneObj, bool needSetMask = false, GameObject parentObj = null)
         {
             //角色
             var roleTf = sceneObj.transform.Find(ROLE_OBJ_NAME);
             parentObj = parentObj == null ? roleTf.gameObject : parentObj;
 
             var extPng = "png";
-            if (!string.IsNullOrEmpty(actionRes))
+            string resPath = null;
+            string effectResPath = null;
+            string objName;
+            bool showAni = !string.IsNullOrEmpty(actionRes);
+            string aniResPath = null;
+            if (showAni)
             {
-                string resPath = ResPathUtil.GetDressUpAnimationPath(actionRes);
-                if (GetGameObjExisted(parentObj, BODY_ANIMATION_NAME, resPath) != null)
+                aniResPath = ResPathUtil.GetDressUpAnimationPath(actionRes);
+                if(!YooAssets.CheckResExist(aniResPath))
                 {
-                    return;
+                    showAni = false;
                 }
             }
-            else
+            if(showAni)
             {
-                string resPath = ResPathUtil.GetDressUpPath(BODY_DEFAULT_RES_NAME, extPng);
-                if (GetGameObjExisted(parentObj, BODY_SPRITE_NAME, resPath) != null)
+                resPath = aniResPath;
+                objName = BODY_ANIMATION_NAME;
+                //特效
+                effectResPath = ResPathUtil.GetDressUpEffectPath(actionRes, true);
+                if (!YooAssets.CheckResExist(effectResPath))
                 {
-                    return;
+                    effectResPath = null;
                 }
             }
-
-            var removeBodyAni = TryRemoveObj(parentObj, BODY_ANIMATION_NAME);
-            TryRemoveObj(parentObj, BODY_EFFECT_OBJ_NAME);
-            TryRemoveObj(parentObj, BODY_SPRITE_NAME);
-            if (!string.IsNullOrEmpty(actionRes))
+            else
             {
-                var addAniObj = AddAnimationObj(actionRes, BODY_ANIMATION_NAME, parentObj, 0);
-                //特效
-                TryAddEffectObj(actionRes, BODY_EFFECT_OBJ_NAME, parentObj, 0, addAniObj != null);
+                resPath = ResPathUtil.GetDressUpPath(BODY_DEFAULT_RES_NAME, extPng);
+                objName = BODY_SPRITE_NAME;
             }
-            else
+            if (GetGameObjExisted(parentObj, objName, resPath) != null || !YooAssets.CheckResExist(resPath))
             {
-                AddSpriteObj(ResPathUtil.GetDressUpPath(BODY_DEFAULT_RES_NAME), extPng, BODY_SPRITE_NAME, parentObj, 0, needSetMask);
-                if (removeBodyAni)
-                {
-                    parentObj.transform.SetPositionAndRotation(new Vector3(), new Quaternion());
-                }
+                return null;
             }
+            DressUpLayerOperation handler = new DressUpLayerOperation(parentObj, needSetMask, showAni, resPath, effectResPath);
+            handler.InitBody();
+            handler.Begin();
+            return handler;
         }
 
-        private static void updateLayerRes(ItemCfg itemCfg, GameObject parentObj, int layerId, bool needSetMask, bool showAni = true)
-        {
+        //private static void UpdateLayerRes(ItemCfg itemCfg, GameObject parentObj, int layerId, bool needSetMask, bool showAni = true)
+        //{
+        //    string res = ResPathUtil.GetDressUpItemLayerRes(itemCfg, layerId);
+        //    string resPath = ResPathUtil.GetDressUpPath(itemCfg, layerId);
+        //    int sortingOrder = ItemTypeCfgArray.Instance.GetSortingOrder(itemCfg.subType, layerId);
+
+        //    //清理旧的
+        //    var spritObjName = string.Format(FORMAT_SPRITE_NAME, itemCfg.subType, layerId);
+        //    TryRemoveObj(parentObj, spritObjName);
+        //    var objName = string.Format(FORMAT_ANIMATION_NAME, itemCfg.subType, layerId);
+        //    TryRemoveObj(parentObj, objName);
+        //    string ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType);
+        //    GameObject spriteObj = null;
+        //    if (DressUpMenuItemCfg1Array.Instance.CheckIsDefaultType(itemCfg.subType))
+        //    {
+        //        //默认类型的部件需要先添加静态图,防止加载动画有延迟,出现光头
+        //        spriteObj = AddSpriteObj(resPath, spritObjName, parentObj, sortingOrder, needSetMask);
+        //    }
 
-            ItemTypeCfg typeCfg = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType);
+        //    GameObject addAniObj = null;
+        //    if (showAni)
+        //    {
+        //        string aniResPath = ResPathUtil.GetDressUpAnimationPath(res);
+        //        addAniObj = AddAnimationObj(aniResPath, objName, parentObj, sortingOrder);
+        //        if (addAniObj != null && spriteObj != null)
+        //        {
+        //            var dressUpPart = addAniObj.GetComponent<DressUpPart>();
+        //            if (dressUpPart == null)
+        //            {
+        //                dressUpPart = addAniObj.AddComponent<DressUpPart>();
+        //            }
+        //            dressUpPart.OnTimer = (obj) =>
+        //            {
+        //                if (parentObj != null && parentObj.transform != null)
+        //                {
+        //                    string resPath = ResPathUtil.GetDressUpPath(itemCfg, layerId);
+        //                    spriteObj = GetGameObjExisted(parentObj, spritObjName, resPath);
+        //                    if (spriteObj != null)
+        //                    {
+        //                        PrefabManager.Instance.Restore(spriteObj);
+        //                    }
 
+        //                    //Transform tf = parentObj.transform.Find(spritObjName);
+        //                    //if (tf != null && tf.gameObject != null && tf.gameObject.activeInHierarchy)
+        //                    //{
+        //                    //    var assetDisposer = tf.gameObject.GetComponent<AssetReleaser>();
+        //                    //    if (assetDisposer != null)
+        //                    //    {
+        //                    //        if (!string.IsNullOrEmpty(assetDisposer.resPath))
+        //                    //        {
+        //                    //            string resPath = ResPathUtil.GetDressUpPath(itemCfg, layerId);
+        //                    //            if (assetDisposer.resPath == resPath)
+        //                    //            {
+        //                    //                TryRemoveObj(parentObj, spritObjName);
+        //                    //            }
+        //                    //        }
+        //                    //    }
+        //                    //}
+        //                }
+        //            };
+        //            Timers.inst.Add(0.03f, 1, dressUpPart.OnTimer);
+        //        }
+        //    }
+        //    if (spriteObj == null && addAniObj == null)
+        //    {
+        //        //如果两个都没有,就添加静态图
+        //        spriteObj = AddSpriteObj(resPath, spritObjName, parentObj, sortingOrder, needSetMask);
+        //    }
+        //    objName = string.Format(FORMAT_EFFECT_OBJ_NAME, itemCfg.subType, layerId);
+        //    TryRemoveObj(parentObj, objName);
+        //    resPath = ResPathUtil.GetDressUpEffectPath(res, addAniObj != null);
+        //    TryAddEffectObj(resPath, objName, parentObj, sortingOrder);
+        //}
+
+        private static DressUpLayerOperation UpdateLayerResAsync(ItemCfg itemCfg, GameObject parentObj, int layerId, bool needSetMask, bool showAni = true)
+        {
             string res = ResPathUtil.GetDressUpItemLayerRes(itemCfg, layerId);
-            string resPath = ResPathUtil.GetDressUpPath(itemCfg, layerId);
-            int sortingOrder = typeCfg.defaultLayer;
-            if (layerId == 2)
+            string resPath;
+            string aniResPath = null;
+            //根据资源存在与否再次检查是否播放动画
+            if (showAni)
             {
-                sortingOrder = typeCfg.specialLayer;
+                aniResPath = ResPathUtil.GetDressUpAnimationPath(res);
+                if(!YooAssets.CheckResExist(aniResPath))
+                {
+                    showAni = false;
+                }
             }
-            else if (layerId == 3)
+
+            string objName;
+            if (showAni)
             {
-                sortingOrder = typeCfg.thirdlLayer;
+                resPath = aniResPath;
+                objName = string.Format(DressUpUtil.FORMAT_ANIMATION_NAME, itemCfg.subType, layerId);
             }
-
-            //清理旧的
-            var spritObjName = string.Format(FORMAT_SPRITE_NAME, itemCfg.subType, layerId);
-            TryRemoveObj(parentObj, spritObjName);
-            var objName = string.Format(FORMAT_ANIMATION_NAME, itemCfg.subType, layerId);
-            TryRemoveObj(parentObj, objName);
-            string ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType);
-            GameObject spriteObj = null;
-            if (DressUpMenuItemCfg1Array.Instance.CheckIsDefaultType(itemCfg.subType))
+            else
             {
-                //默认类型的部件需要先添加静态图,防止加载动画有延迟,出现光头
-                spriteObj = AddSpriteObj(resPath, ext, spritObjName, parentObj, sortingOrder, needSetMask);
+                resPath = ResPathUtil.GetDressUpPath(itemCfg, layerId);
+                objName = string.Format(DressUpUtil.FORMAT_SPRITE_NAME, itemCfg.subType, layerId);
             }
 
-            GameObject addAniObj = null;
-            if (showAni)
+            var gameObj = DressUpUtil.GetGameObjExisted(parentObj, objName, resPath);
+            if (gameObj != null || !YooAssets.CheckResExist(resPath))
             {
-                addAniObj = AddAnimationObj(res, objName, parentObj, sortingOrder);
-                if (addAniObj != null && spriteObj != null)
-                {
-                    var dressUpPart = addAniObj.GetComponent<DressUpPart>();
-                    if (dressUpPart == null)
-                    {
-                        dressUpPart = addAniObj.AddComponent<DressUpPart>();
-                    }
-                    dressUpPart.OnTimer = (obj) =>
-                    {
-                        if (parentObj != null && parentObj.transform != null)
-                        {
-                            string resPath = ResPathUtil.GetDressUpPath(itemCfg, layerId);
-                            spriteObj = GetGameObjExisted(parentObj, spritObjName, resPath);
-                            if(spriteObj != null)
-                            {
-                                PrefabManager.Instance.Restore(spriteObj);
-                            }
-
-                            //Transform tf = parentObj.transform.Find(spritObjName);
-                            //if (tf != null && tf.gameObject != null && tf.gameObject.activeInHierarchy)
-                            //{
-                            //    var assetDisposer = tf.gameObject.GetComponent<AssetReleaser>();
-                            //    if (assetDisposer != null)
-                            //    {
-                            //        if (!string.IsNullOrEmpty(assetDisposer.resPath))
-                            //        {
-                            //            string resPath = ResPathUtil.GetDressUpPath(itemCfg, layerId);
-                            //            if (assetDisposer.resPath == resPath)
-                            //            {
-                            //                TryRemoveObj(parentObj, spritObjName);
-                            //            }
-                            //        }
-                            //    }
-                            //}
-                        }
-                    };
-                    Timers.inst.Add(0.03f, 1, dressUpPart.OnTimer);
-                }
+                return null;
             }
-            if (spriteObj == null && addAniObj == null)
+
+            //特效
+            string effectResPath = ResPathUtil.GetDressUpEffectPath(res, showAni);
+            if (!YooAssets.CheckResExist(effectResPath))
             {
-                //如果两个都没有,就添加静态图
-                spriteObj = AddSpriteObj(resPath, ext, spritObjName, parentObj, sortingOrder, needSetMask);
+                effectResPath = null;
             }
-            objName = string.Format(FORMAT_EFFECT_OBJ_NAME, itemCfg.subType, layerId);
-            TryRemoveObj(parentObj, objName);
-            TryAddEffectObj(res, objName, parentObj, sortingOrder, addAniObj != null);
+            DressUpLayerOperation handler = new DressUpLayerOperation(parentObj, needSetMask, showAni, resPath, effectResPath);
+            handler.InitLayer(itemCfg, layerId);
+            handler.Begin();
+            return handler;
         }
 
-        private static GameObject AddSpriteObj(string resPath, string ext, string objName, GameObject parentObj, int sortingOrder, bool needSetMask)
+        public static GameObject AddSpriteObj(string resPath, string objName, GameObject parentObj, int sortingOrder, bool needSetMask)
         {
             if (!YooAssets.CheckResExist(resPath))
             {
@@ -334,9 +516,8 @@ namespace GFGGame
             return gameObj;
         }
 
-        private static GameObject AddAnimationObj(string res, string objName, GameObject parentObj, int sortingOrder)
+        public static GameObject AddAnimationObj(string resPath, string objName, GameObject parentObj, int sortingOrder)
         {
-            string resPath = ResPathUtil.GetDressUpAnimationPath(res);
             var gameObj = GetGameObjExisted(parentObj, objName, resPath);
             if (gameObj != null)
             {
@@ -372,9 +553,8 @@ namespace GFGGame
             return gameObj;
         }
 
-        private static GameObject TryAddEffectObj(string res, string objName, GameObject parentObj, int sortingOrder, bool inAniDir)
+        public static GameObject TryAddEffectObj(string resPath, string objName, GameObject parentObj, int sortingOrder)
         {
-            var resPath = ResPathUtil.GetDressUpEffectPath(res, inAniDir);
             var gameObj = GetGameObjExisted(parentObj, objName, resPath);
             if (gameObj != null)
             {
@@ -396,7 +576,7 @@ namespace GFGGame
             return gameObj;
         }
 
-        private static bool TryRemoveObj(GameObject parentObj, string objName)
+        public static bool TryRemoveObj(GameObject parentObj, string objName)
         {
             if (parentObj == null)
             {
@@ -415,7 +595,7 @@ namespace GFGGame
             return false;
         }
 
-        private static GameObject GetGameObjExisted(GameObject parentObj, string objName, string resPath)
+        public static GameObject GetGameObjExisted(GameObject parentObj, string objName, string resPath)
         {
             if (parentObj == null)
             {
@@ -478,7 +658,7 @@ namespace GFGGame
             }
         }
 
-        public static void SetRenderersOrder(GameObject gameObj, int sortingOrder, bool isAdd = false)
+        private static void SetRenderersOrder(GameObject gameObj, int sortingOrder, bool isAdd = false)
         {
             var meshRenderers = gameObj.transform.GetComponentsInChildren<MeshRenderer>();
             for (int i = 0; i < meshRenderers.Length; i++)
@@ -514,23 +694,23 @@ namespace GFGGame
                 }
             }
         }
-        public static void SetSpriteRenderSortingOrder(GameObject gameObj, int sortingOrder, bool isAdd = false)
-        {
-            SpriteRenderer[] spriteRenders = gameObj.transform.GetComponentsInChildren<SpriteRenderer>();
-            for (int i = 0; i < spriteRenders.Length; i++)
-            {
+        //public static void SetSpriteRenderSortingOrder(GameObject gameObj, int sortingOrder, bool isAdd = false)
+        //{
+        //    SpriteRenderer[] spriteRenders = gameObj.transform.GetComponentsInChildren<SpriteRenderer>();
+        //    for (int i = 0; i < spriteRenders.Length; i++)
+        //    {
 
-                if (isAdd)
-                {
-                    spriteRenders[i].sortingOrder = spriteRenders[i].sortingOrder + sortingOrder;
-                }
-                else
-                {
+        //        if (isAdd)
+        //        {
+        //            spriteRenders[i].sortingOrder = spriteRenders[i].sortingOrder + sortingOrder;
+        //        }
+        //        else
+        //        {
 
-                    spriteRenders[i].sortingOrder = sortingOrder;
-                }
-            }
-        }
+        //            spriteRenders[i].sortingOrder = sortingOrder;
+        //        }
+        //    }
+        //}
     }
 
 }

+ 22 - 2
GameClient/Assets/Game/HotUpdate/Live2d/Live2dAnimationManager.cs

@@ -1,7 +1,27 @@
-namespace GFGGame
+using GFGGame.Launcher;
+using UnityEngine;
+
+namespace GFGGame
 {
-    public class Live2dAnimationManager : SingletonBase<Live2dAnimationManager>
+    public class Live2dAnimationManager : SingletonMonoBase<Live2dAnimationManager>
     {
+        private GameObject preDrawRoot;
+        private void Awake()
+        {
+            preDrawRoot = new GameObject("Live2dAnimationManager");
+            preDrawRoot.transform.position = new Vector3(100, 0, 0);
+        }
+
+        public GameObject PreDraw(string resPath)
+        {
+            var t = PrefabManager.Instance.SpawnSync(resPath);
+            t.transform.SetParent(preDrawRoot.transform, false);
+            return t;
+        }
 
+        public void FinishPreDrawed(GameObject t)
+        {
+            PrefabManager.Instance.Restore(t);
+        }
     }
 }

+ 1 - 0
GameClient/Assets/Game/HotUpdate/OperationSystem/AsyncOperationBase.cs

@@ -2,6 +2,7 @@
 using System.Collections;
 using System.Collections.Generic;
 using System.Threading.Tasks;
+using YooAsset;
 
 namespace GFGGame
 {

+ 0 - 10
GameClient/Assets/Game/HotUpdate/OperationSystem/EOperationStatus.cs

@@ -1,10 +0,0 @@
-
-namespace GFGGame
-{
-	public enum EOperationStatus
-	{
-		None,
-		Succeed,
-		Failed
-	}
-}

+ 1 - 3
GameClient/Assets/YooAsset/Runtime/GFG/YooAssetsExtensionGFG.cs

@@ -1,6 +1,4 @@
-using static Google.Protobuf.Reflection.UninterpretedOption.Types;
-
-namespace YooAsset
+namespace YooAsset
 {
     public static partial class YooAssets
     {