Browse Source

拍照边框可移动缩放

zhaoyang 2 years ago
parent
commit
e2cf00b036

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

@@ -25,12 +25,16 @@ namespace GFGGame
             {
             {
                 spr.sprite = null;
                 spr.sprite = null;
             }
             }
-            if (itemCfg.id == ConstItemID.BORDERID) return;
+            if (itemCfg.id == ConstItemID.BORDERID)
+            {
+                SceneController.DeleteBoxCollider2DFromGameObject(tf.gameObject);
+                return;
+            }
             string resPath = ResPathUtil.GetPhotographBorderPath(itemCfg.res, ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType));
             string resPath = ResPathUtil.GetPhotographBorderPath(itemCfg.res, ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType));
             SceneController.SetSpriteRendererToTransform(tf, resPath);
             SceneController.SetSpriteRendererToTransform(tf, resPath);
             spr = tf.GetComponent<SpriteRenderer>();
             spr = tf.GetComponent<SpriteRenderer>();
             spr.sortingOrder = 10000;//边框在所有道具的上边
             spr.sortingOrder = 10000;//边框在所有道具的上边
-
+            SceneController.SetBoxCollider2DToGameObject(tf.gameObject);
         }
         }
         public void AddSceneItem(GameObject parentGameObj, ItemCfg itemCfg, int layer, bool setLayer)
         public void AddSceneItem(GameObject parentGameObj, ItemCfg itemCfg, int layer, bool setLayer)
         {
         {

+ 9 - 1
GameClient/Assets/Game/HotUpdate/DressUp/SceneController.cs

@@ -248,11 +248,19 @@ namespace GFGGame
             {
             {
                 GameObject.Destroy(polygonCollider2D);
                 GameObject.Destroy(polygonCollider2D);
             }
             }
-
             polygonCollider2D = gameObject.AddComponent<BoxCollider2D>();
             polygonCollider2D = gameObject.AddComponent<BoxCollider2D>();
             polygonCollider2D.isTrigger = true;
             polygonCollider2D.isTrigger = true;
 
 
         }
         }
+        //移除指定GameObject的BoxCollider2D
+        public static void DeleteBoxCollider2DFromGameObject(GameObject gameObject)
+        {
+            BoxCollider2D polygonCollider2D = gameObject.GetComponent<BoxCollider2D>();
+            if (polygonCollider2D != null)
+            {
+                GameObject.Destroy(polygonCollider2D);
+            }
+        }
 
 
 
 
 
 

+ 22 - 4
GameClient/Assets/Game/HotUpdate/Views/DressUp/PhotographView.cs

@@ -28,6 +28,7 @@ namespace GFGGame
         private const string NpcPath = "Scene/Npc";
         private const string NpcPath = "Scene/Npc";
         private const string NpcName = "Npc";
         private const string NpcName = "Npc";
         private const string BgResName = "BgRes";
         private const string BgResName = "BgRes";
+        private const string Border = "Border";
 
 
         private List<int> _listData = null;//当前选择的资源数据
         private List<int> _listData = null;//当前选择的资源数据
         private List<GameObject> _itemGameObjs;// = new List<GameObject>();
         private List<GameObject> _itemGameObjs;// = new List<GameObject>();
@@ -174,12 +175,17 @@ namespace GFGGame
         }
         }
         private void OnListItemClick(EventContext context)
         private void OnListItemClick(EventContext context)
         {
         {
-            if (_itemGameObjs.Count >= MAX_COUNT)
+            EnumPhotographType type = (EnumPhotographType)_ui.m_ComSelectRes.m_comBtnTab.m_c1.selectedIndex;
+            if (type == EnumPhotographType.SCENE && _itemGameObjs.Count >= MAX_COUNT)
             {
             {
                 PromptController.Instance.ShowFloatTextPrompt("最多穿戴" + MAX_COUNT + "件物品");
                 PromptController.Instance.ShowFloatTextPrompt("最多穿戴" + MAX_COUNT + "件物品");
                 return;
                 return;
             }
             }
             int itemID = (int)((context.data as GObject).data);
             int itemID = (int)((context.data as GObject).data);
+            ChangeItem(itemID);
+        }
+        private void ChangeItem(int itemID)
+        {
             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemID);
             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemID);
 
 
             EnumPhotographType type = (EnumPhotographType)_ui.m_ComSelectRes.m_comBtnTab.m_c1.selectedIndex;
             EnumPhotographType type = (EnumPhotographType)_ui.m_ComSelectRes.m_comBtnTab.m_c1.selectedIndex;
@@ -191,7 +197,6 @@ namespace GFGGame
                     break;
                     break;
 
 
                 case EnumPhotographType.BORDER:
                 case EnumPhotographType.BORDER:
-
                     PhotographSceneManager.Instance.AddBorderItem(itemCfg);
                     PhotographSceneManager.Instance.AddBorderItem(itemCfg);
                     break;
                     break;
 
 
@@ -287,8 +292,10 @@ namespace GFGGame
                     hitGameObj = hitGameObj.transform.parent.gameObject;
                     hitGameObj = hitGameObj.transform.parent.gameObject;
 
 
                     _ui.m_comSelectBox.target.visible = true;
                     _ui.m_comSelectBox.target.visible = true;
-
-                    PhotographDataManager.Instance.SetLayer(hitGameObj, "top");
+                    if (hitGameObj.name != Border)
+                    {
+                        PhotographDataManager.Instance.SetLayer(hitGameObj, "top");
+                    }
 
 
                     if (!_equipDistance.ContainsKey(hitGameObj))
                     if (!_equipDistance.ContainsKey(hitGameObj))
                     {
                     {
@@ -486,6 +493,10 @@ namespace GFGGame
             {
             {
                 return;
                 return;
             }
             }
+            else if (memoryHitGameObj.transform.name == Border)
+            {
+                ChangeItem(ConstItemID.BORDERID);
+            }
             else if (memoryHitGameObj.transform.name == NpcName)
             else if (memoryHitGameObj.transform.name == NpcName)
             {
             {
                 SpriteRenderer spriteRenderer = memoryHitGameObj.transform.GetChild(0).GetComponent<SpriteRenderer>();
                 SpriteRenderer spriteRenderer = memoryHitGameObj.transform.GetChild(0).GetComponent<SpriteRenderer>();
@@ -508,6 +519,13 @@ namespace GFGGame
             _ui.m_comSelectBox.target.visible = false;
             _ui.m_comSelectBox.target.visible = false;
             hitGameObj = null;
             hitGameObj = null;
             memoryHitGameObj = null;
             memoryHitGameObj = null;
+            _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)
+            {
+                _ui.m_ComSelectRes.m_list.ScrollToView(0);
+                _ui.m_ComSelectRes.m_list.selectedIndex = 0;
+            }
         }
         }
 
 
         private void OnClickBtnUp()
         private void OnClickBtnUp()