Parcourir la source

修复背包部分UI不匹配问题

WGL il y a 1 mois
Parent
commit
786688b1d9

+ 6 - 6
ActionTowerDefense/Assets/Resources/Prefab/RougueUI/Shop_UI.prefab

@@ -1371,7 +1371,7 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   m_Material: {fileID: 0}
   m_Color: {r: 1, g: 1, b: 1, a: 1}
-  m_RaycastTarget: 1
+  m_RaycastTarget: 0
   m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
   m_Maskable: 1
   m_OnCullStateChanged:
@@ -1446,7 +1446,7 @@ MonoBehaviour:
     m_PersistentCalls:
       m_Calls: []
   m_Sprite: {fileID: 0}
-  m_Radius: 110
+  m_Radius: 105
   m_SideCount: 8
   m_ShowInner: 1
   m_ShowOutline: 1
@@ -1454,9 +1454,9 @@ MonoBehaviour:
     width: 1
     color: {r: 1, g: 1, b: 1, a: 1}
   m_RatioList:
-  - 0.914
-  - 0.317
-  - 0.773
+  - 1
+  - 1
+  - 1
   - 1
   - 1
   - 1
@@ -3785,7 +3785,7 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   m_Material: {fileID: 2100000, guid: 774d3eac0093d1049a171c7ea1aca258, type: 2}
   m_Color: {r: 1, g: 1, b: 1, a: 0.29803923}
-  m_RaycastTarget: 1
+  m_RaycastTarget: 0
   m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
   m_Maskable: 1
   m_OnCullStateChanged:

+ 3 - 3
ActionTowerDefense/Assets/Resources/Prefab/RougueUI/Treasure.prefab

@@ -183,14 +183,14 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   m_Material: {fileID: 0}
-  m_Color: {r: 0.47843137, g: 0.47843137, b: 0.47843137, a: 1}
+  m_Color: {r: 1, g: 1, b: 1, a: 1}
   m_RaycastTarget: 1
   m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
   m_Maskable: 1
   m_OnCullStateChanged:
     m_PersistentCalls:
       m_Calls: []
-  m_Sprite: {fileID: 0}
+  m_Sprite: {fileID: 21300000, guid: b038a2f81c8fd7b4d9ac8dc037e6b2be, type: 3}
   m_Type: 0
   m_PreserveAspect: 0
   m_FillCenter: 1
@@ -215,6 +215,6 @@ MonoBehaviour:
   image: {fileID: 220482037564887049}
   background: {fileID: 6256315506709047983}
   sprite: {fileID: 0}
-  color: {r: 0, g: 0, b: 0, a: 0}
+  box: {fileID: 0}
   treasuresSaleUI: {fileID: 0}
   shopUI: {fileID: 0}

+ 3 - 6
ActionTowerDefense/Assets/Resources/Prefab/RougueUI/TreasureDetails.prefab

@@ -911,7 +911,7 @@ RectTransform:
   m_AnchorMin: {x: 0.5, y: 0.5}
   m_AnchorMax: {x: 0.5, y: 0.5}
   m_AnchoredPosition: {x: 0, y: 0}
-  m_SizeDelta: {x: 275, y: 500}
+  m_SizeDelta: {x: 275, y: 470}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!222 &8711468481046420485
 CanvasRenderer:
@@ -980,9 +980,6 @@ MonoBehaviour:
   attribute: {fileID: 1508974979500203315}
   buy: {fileID: 3648198651598870817}
   price: {fileID: 9007231733490116374}
-  TreasureBackgrounds:
-  - {fileID: 21300000, guid: 8f3b16bc9aa84a840a8241b05e628e4e, type: 3}
-  - {fileID: 21300000, guid: 9e6f22d4e598bb84db092780d40f392c, type: 3}
   background: {fileID: 3265704620539566501}
   islock: 0
   isNull: 0
@@ -1393,7 +1390,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0.5, y: 1}
   m_AnchorMax: {x: 0.5, y: 1}
-  m_AnchoredPosition: {x: 0, y: -449}
+  m_AnchoredPosition: {x: 0, y: -450}
   m_SizeDelta: {x: 100, y: 100}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!1 &6154977542788410848
@@ -1920,7 +1917,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 1}
   m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: 85.6, y: -377.1}
+  m_AnchoredPosition: {x: 85.6, y: -395}
   m_SizeDelta: {x: 30, y: 30}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!222 &247275032043267853

Fichier diff supprimé car celui-ci est trop grand
+ 0 - 991
ActionTowerDefense/Assets/Resources/Prefab/RougueUI/TreasureDetails_inBag.prefab


+ 19 - 33
ActionTowerDefense/Assets/Scripts/UI/ShopUI.cs

@@ -3,7 +3,7 @@ using Sirenix.OdinInspector;
 using System.Collections.Generic;
 using TMPro;
 using UnityEngine;
-
+using UnityEngine.UI;
 
 public class ShopUI : MonoBehaviour
 {
@@ -132,7 +132,6 @@ public class ShopUI : MonoBehaviour
             //randomTreasure.Add(singleTreasureConfig.ID);
         }
         DrawUIPolygon();
-        DrawBag();
         gameObject.SetActive(true);
     }
 
@@ -164,38 +163,25 @@ public class ShopUI : MonoBehaviour
         radarChart.SetRatioList(polygon);
     }
 
-    public void DrawBag()
+    public void AddTreasureInBag()
     {
         List<Treasure> treasures = GameManager.instance.myTreasures;
-        for(int i = 0; i < treasures.Count; i++)
-        {
-            TreasureInBag treasureInBag;
-            TreasuresSaleUI treasuresSaleUI;
-            if (i >= bagContent.childCount)
-            {
-                GameObject obj = Instantiate(this.treasureInBag,bagContent);
-                GameObject objDetails = Instantiate(treasureDetails_inBag, detailsParent);
-                objDetails.SetActive(false);
-                treasureInBag = obj.GetComponent<TreasureInBag>();
-                treasuresSaleUI = objDetails.GetComponent<TreasuresSaleUI>();
-            }
-            else
-            {
-                treasureInBag = bagContent.GetChild(i).GetComponent<TreasureInBag>();
-                treasuresSaleUI = detailsParent.GetChild(i).GetComponent<TreasuresSaleUI>();
-            }
-            treasureInBag.treasuresSaleUI = treasuresSaleUI;
-            treasureInBag.sprite = treasures[i].sprite;
-            treasureInBag.box = treasures[i].qualityBox;
-            treasureInBag.shopUI = this;
-            treasuresSaleUI.owner = treasureInBag;
-            treasuresSaleUI.treasure = treasures[i];
-            treasuresSaleUI.transform.position = treasureInBag.transform.position;
-            treasureInBag.Refresh();
-        }
-        for(int i = treasures.Count; i < bagContent.childCount; i++)
-        {
-            Destroy(bagContent.GetChild(i));
-        }
+        Treasure treasure = treasures[treasures.Count - 1];
+        TreasureInBag treasureInBag;
+        TreasuresSaleUI treasuresSaleUI;
+        GameObject obj = Instantiate(this.treasureInBag, bagContent);
+        GameObject objDetails = Instantiate(treasureDetails_inBag, detailsParent);
+        objDetails.SetActive(false);
+        treasureInBag = obj.GetComponent<TreasureInBag>();
+        treasuresSaleUI = objDetails.transform.GetChild(0).GetComponent<TreasuresSaleUI>();
+        treasureInBag.treasuresSaleUI = treasuresSaleUI;
+        treasureInBag.sprite = treasure.sprite;
+        treasureInBag.box = treasure.qualityBox;
+        treasureInBag.shopUI = this;
+        treasureInBag.GetComponent<Image>().sprite = treasure.sprite;
+        treasuresSaleUI.owner = treasureInBag;
+        treasuresSaleUI.treasure = treasure;
+        treasuresSaleUI.transform.parent.position = treasureInBag.transform.position;
+        treasureInBag.Refresh();
     }
 }

+ 2 - 2
ActionTowerDefense/Assets/Scripts/UI/TreasureInBag.cs

@@ -22,11 +22,11 @@ public class TreasureInBag : MonoBehaviour
 
     public void ShowDetails()
     {
-        treasuresSaleUI.gameObject.SetActive(true);
+        treasuresSaleUI.transform.parent.gameObject.SetActive(true);
     }
 
     public void HideDetails()
     {
-        treasuresSaleUI.gameObject.SetActive(false);
+        treasuresSaleUI.transform.parent.gameObject.SetActive(false);
     }
 }

+ 3 - 3
ActionTowerDefense/Assets/Scripts/UI/TreasuresSaleUI.cs

@@ -57,7 +57,7 @@ public class TreasuresSaleUI : MonoBehaviour
     {
         if(owner != null)
         {
-            transform.position = owner.transform.position;
+            transform.parent.position = owner.transform.position;
         }
         
     }
@@ -65,7 +65,7 @@ public class TreasuresSaleUI : MonoBehaviour
     {
         if(owner!=null && gameObject.activeSelf)
         {
-            transform.position = owner.transform.position;
+            transform.parent.position = owner.transform.position;
         }
     }
 
@@ -167,7 +167,7 @@ public class TreasuresSaleUI : MonoBehaviour
         }
         gameManager.maxTreasuresTag = id;
         shopUI.DrawUIPolygon();
-        shopUI.DrawBag();
+        shopUI.AddTreasureInBag();
         gameObject.SetActive(false);
         isNull = true;
         islock = false;

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff