Browse Source

修复拍照的位置显示问题

leiyasi 1 year ago
parent
commit
4626597194

+ 6 - 0
GameClient/Assets/Game/HotUpdate/Data/PhotographSceneManager.cs

@@ -24,6 +24,12 @@ namespace GFGGame
         public void AddBorderItem(ItemCfg itemCfg)
         {
             Transform tf = sceneObject.transform.Find("Border/BorderRes");
+
+            // 刷新父节点Border的数据
+            tf.parent.position = Vector3.zero;
+            tf.parent.eulerAngles = Vector3.zero;
+            tf.parent.localScale = Vector3.one;
+
             string resPath;
 
             if (itemCfg.id != ConstItemID.BORDERID)

+ 5 - 1
GameClient/Assets/Game/HotUpdate/Data/PhotographUtil.cs

@@ -42,14 +42,18 @@ namespace GFGGame
         //设置物体中心点
         public async Task SetGameObjectCenter(GameObject parentObj)
         {
+            // 先隐藏,不然位置会出现闪一下
+            parentObj.SetActive(false);
             await Task.Delay(5);
+            parentObj.SetActive(true);
             Transform parent = parentObj.transform;  // 2.选中技算
             Vector3 postion = parent.position;
             Quaternion rotation = parent.rotation;
-            Vector3 scale = parent.localScale;
+           
             parent.position = Vector3.zero;
             parent.rotation = Quaternion.Euler(Vector3.zero);
             parent.localScale = Vector3.one;
+            Vector3 scale = parent.localScale;
             Vector3 center = Vector3.zero;
             int index = 0;
             foreach (Transform t in parent)

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Views/Common/Controller/LuckyBoxController.cs

@@ -257,7 +257,7 @@ namespace GFGGame
 
         private void ChangeModelAlphaAnim(int index, float start, float end, Action action = null)
         {
-            Ease ease = start < end ? Ease.InQuad : Ease.OutQuad;
+            Ease ease = Ease.OutQuad;
             DOTween.To(() => start, (value) =>
             {
                 ChangeModelAlpha(index, value);

+ 72 - 3
GameClient/Assets/Game/HotUpdate/Views/DressUp/PhotographView.cs

@@ -51,6 +51,10 @@ namespace GFGGame
         private PinchGesture pinchGesture;
         private RotationGesture rotationGesture;
 
+        // 以下两个属于单选,单独保存
+        private int lastChooseBorder;       // 上一次选择的边框
+        private int lastChooseBg;           // 上一次选择的背景
+
         public override void Dispose()
         {
             if (_sceneObject != null)
@@ -78,7 +82,7 @@ namespace GFGGame
 
             _ui.m_btnBg.onClick.Add(OnClickBtnBg);
 
-            _ui.m_btnChoose.onClick.Add(SetUIView);
+            _ui.m_btnChoose.onClick.Add(OnClickBtnChoose);
             _ui.m_btnBack.onClick.Add(OnClickBtnBack);
             _ui.m_btnPhotograph.onClick.Add(OnClickBtnPhotograph);
             _ui.m_btnGalleryJoin.onClick.Add(OnClickBtnGalleryJoin);
@@ -136,6 +140,7 @@ namespace GFGGame
             RefreshList(EnumPhotographType.BG);
             SetUIView();
             PhotographSceneManager.Instance.AddBgItem(ItemCfgArray.Instance.GetCfg(MyDressUpHelper.dressUpObj.bgId));
+            SetListScrollByID(MyDressUpHelper.dressUpObj.bgId);
             PhotographSceneManager.Instance.AddBodyItem();
             UpdateScene();
             PhotographUtil.Instance.SetLayer(null, "refresh");
@@ -144,23 +149,63 @@ namespace GFGGame
 
             Timers.inst.AddUpdate(CheckGuide);
         }
+
         /************************************************************UI界面*********************************************************/
         private void OnContorllerChanged(EventContext context)
         {
             int index = _ui.m_ComSelectRes.m_comBtnTab.m_c1.selectedIndex;
             RefreshList((EnumPhotographType)index);
         }
+
         private void RefreshList(EnumPhotographType index)
         {
             _ui.m_ComSelectRes.m_list.numItems = 0;
 
             _listData = PhotographDataManager.Instance.GetListData(index);
             _ui.m_ComSelectRes.m_list.numItems = _listData.Count;
-            if (index == EnumPhotographType.BORDER || index == EnumPhotographType.EFFECT)
+
+            bool setTop = false;
+            switch (index)
             {
-                _ui.m_ComSelectRes.m_list.selectedIndex = 0;
+                case EnumPhotographType.BORDER:
+                    _ui.m_ComSelectRes.m_list.selectedIndex = lastChooseBorder;
+                    break;
+
+                case EnumPhotographType.BG:
+                    _ui.m_ComSelectRes.m_list.selectedIndex = lastChooseBg;
+                    break;
+                default:
+                    setTop = true;
+                    break;
+            }
+
+            if (!setTop)
+            {
+                _ui.m_ComSelectRes.m_list.ScrollToView(_ui.m_ComSelectRes.m_list.selectedIndex);
+            }
+            else
+            {
+                _ui.m_ComSelectRes.m_list.scrollPane.ScrollTop();
+            }
+            //if (index == EnumPhotographType.BORDER || index == EnumPhotographType.EFFECT)
+            //{
+            //    _ui.m_ComSelectRes.m_list.selectedIndex = 0;
+            //}
+        }
+
+        private void SetListScrollByID(int id)
+        {
+            for(int i = 0; i < _listData.Count; i++)
+            {
+                if(id == _listData[i])
+                {
+                    _ui.m_ComSelectRes.m_list.selectedIndex = i;
+                    _ui.m_ComSelectRes.m_list.ScrollToView(_ui.m_ComSelectRes.m_list.selectedIndex);
+                    lastChooseBg = i;
+                }
             }
         }
+
         private void RenderListItem(int index, GObject obj)
         {
             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_listData[index]);
@@ -172,6 +217,7 @@ namespace GFGGame
             item.m_txtName.text = itemCfg.name;
             UI_ListItem.ProxyEnd();
         }
+
         private void OnListItemClick(EventContext context)
         {
             EnumPhotographType type = (EnumPhotographType)_ui.m_ComSelectRes.m_comBtnTab.m_c1.selectedIndex;
@@ -180,9 +226,22 @@ namespace GFGGame
                 PromptController.Instance.ShowFloatTextPrompt("最多穿戴" + MAX_COUNT + "件物品");
                 return;
             }
+
+            switch (type)
+            {
+                case EnumPhotographType.BORDER:
+                    lastChooseBorder = _ui.m_ComSelectRes.m_list.selectedIndex;
+                    break;
+
+                case EnumPhotographType.BG:
+                    lastChooseBg = _ui.m_ComSelectRes.m_list.selectedIndex;
+                    break;
+            }
+
             int itemID = (int)((context.data as GObject).data);
             ChangeItem(itemID);
         }
+
         private void ChangeItem(int itemID)
         {
             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemID);
@@ -512,6 +571,8 @@ namespace GFGGame
             _ui.m_comSelectBox.target.visible = false;
             hitGameObj = null;
             memoryHitGameObj = null;
+            lastChooseBorder = 0;
+            lastChooseBg = 0;
             _ui.m_ComSelectRes.m_comBtnTab.target.scrollPane.SetPercX(0, false);
             _ui.m_ComSelectRes.m_comBtnTab.m_c1.selectedIndex = 0;
             if (_ui.m_ComSelectRes.m_list.numItems > 0)
@@ -521,6 +582,14 @@ namespace GFGGame
             }
         }
 
+        private void OnClickBtnChoose()
+        {
+            _ui.m_ComSelectRes.target.visible = true;
+            _ui.m_comSelectBox.target.visible = false;
+            hitGameObj = null;
+            memoryHitGameObj = null;
+        }
+
         private void OnClickBtnUp()
         {
 

+ 5 - 2
GameClient/Assets/Game/HotUpdate/Views/FieldGuide/DressUpGuideView.cs

@@ -150,8 +150,12 @@ namespace GFGGame
 
         private void RenderListDressUpItem(int index, GObject item)
         {
-            UI_ListDressUpPartsItem listItem = UI_ListDressUpPartsItem.Proxy(item);
+            if(index >= _itemIdList.Count)
+            {
+                return;
+            }
 
+            UI_ListDressUpPartsItem listItem = UI_ListDressUpPartsItem.Proxy(item);
             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemIdList[index]);
             listItem.m_icon.url = ResPathUtil.GetIconPath(itemCfg.res, "png");
             listItem.m_txtTitle.text = itemCfg.name;
@@ -159,7 +163,6 @@ namespace GFGGame
             listItem.m_unlockMask.visible = !DressUpMenuItemDataManager.CheckHasItem(itemCfg.id);
             RarityIconController.UpdateRarityIcon(listItem.m_rarity, _itemIdList[index], false);
             listItem.target.data = _itemIdList[index];
-
             UI_ListDressUpPartsItem.ProxyEnd();
         }