Ver Fonte

3D闸门图标点击显示详细信息加上

Void_F há 2 dias atrás
pai
commit
402c03874a

+ 5 - 5
Assets/Scripts/UI/Item/ZhaMenIconCtrl.cs

@@ -2,6 +2,7 @@ using System;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
+using UnityEngine.Events;
 using UnityEngine.EventSystems;
 using UnityEngine.UI;
 using UnityEngine.UIElements;
@@ -19,7 +20,7 @@ public class ZhaMenIconCtrl : MonoBehaviour, IPointerEnterHandler, IPointerExitH
 
     public Text tintName;
 
-    public void Init(FloodGate data,string name,GameObject targetObj)
+    public void Init(FloodGate data,string name,GameObject targetObj,UnityAction clickAction)
     {
         _data = data;
         tintName.text = name;
@@ -29,10 +30,9 @@ public class ZhaMenIconCtrl : MonoBehaviour, IPointerEnterHandler, IPointerExitH
         _button = this.transform.Find("Icon").GetComponent<UnityEngine.UI.Button>();
 
 
-        _button.onClick.AddListener(() =>
-        {
-            
-        });
+        _button.onClick.AddListener(
+            clickAction
+        );
 
 
         rect.anchoredPosition = new Vector2(2000, 0);

+ 9 - 2
Assets/Scripts/UI/UIView/3D/ZMJKLayer.cs

@@ -100,7 +100,11 @@ public class ZMJKLayer : MonoBehaviour
 
             ZhaMenIconCtrl tempIcon = Instantiate(zhaMenIconOri, zhaMenContent).GetComponent<ZhaMenIconCtrl>();
             tempIcon.Init(GlobalData.floorGateData.buYuan[tempIndex], $"补元:-{tempIndex + 1}#闸门",
-                StaticLod.instance.GetStaticObj($"BY_ZM_{tempIndex + 1:00}"));
+                StaticLod.instance.GetStaticObj($"BY_ZM_{tempIndex + 1:00}"),
+                () =>
+                {
+                    OpenZhaMenInfoPanel(0, tempIndex, tempItem);
+                });
             zhaMenIconList.Add(tempIcon);
         }
 
@@ -121,7 +125,10 @@ public class ZMJKLayer : MonoBehaviour
             
             ZhaMenIconCtrl tempIcon = Instantiate(zhaMenIconOri, zhaMenContent).GetComponent<ZhaMenIconCtrl>();
             tempIcon.Init(GlobalData.floorGateData.taoKou[tempIndex], $"套口:-{tempIndex + 1}#闸门",
-                StaticLod.instance.GetStaticObj($"TK_ZM_{tempIndex + 1:00}"));
+                StaticLod.instance.GetStaticObj($"TK_ZM_{tempIndex + 1:00}"), () =>
+                {
+                    OpenZhaMenInfoPanel(1, tempIndex, tempItem);
+                });
             zhaMenIconList.Add(tempIcon);
         }