Bladeren bron

复制个搜索到3D监控

Void_F 8 maanden geleden
bovenliggende
commit
778e977af0

+ 1 - 0
Assets/Prefabs/UI/SWFZ/SPJK.prefab

@@ -1835,6 +1835,7 @@ MonoBehaviour:
   spjkItemContent: {fileID: 390971722641760305}
   currentObsDataList: []
   countText: {fileID: 5147317439065066957}
+  _obsSearchInputField: {fileID: 6744885183358372171}
 --- !u!1 &4520921689576299114
 GameObject:
   m_ObjectHideFlags: 0

+ 2 - 2
Assets/Scripts/UI/Item/SPJK_ObsItem.cs

@@ -1,3 +1,4 @@
+using System;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
@@ -10,8 +11,7 @@ public class SPJK_ObsItem : MonoBehaviour
     public Text typeText;
     public Text codeText;
     public Text updataTimeText;
-
-
+    
     public void SetData(ObsData data)
     {
         _data = data;

+ 25 - 0
Assets/Scripts/UI/UIView/3D/SPJKLayer.cs

@@ -13,9 +13,14 @@ public class SPJKLayer : MonoBehaviour
     public List<SPJK_ObsItem> currentObsDataList = new List<SPJK_ObsItem>();
 
     public Text countText;
+    
+    public InputField _obsSearchInputField;
+
+  
 
     void Start()
     {
+        
         ObsData[] obs = GlobalData.obsDatas.ToArray();
         for (int i = 0; i < obs.Length; i++)
         {
@@ -24,5 +29,25 @@ public class SPJKLayer : MonoBehaviour
             currentObsDataList.Add(tempItem);
         }
         countText.text = $"监控列表 (<color=#FFFFFF>{obs.Length}</color>)";
+        
+        _obsSearchInputField.onValueChanged.AddListener(SearchObsItem);
+    }
+    
+    public void SearchObsItem(string s_name)
+    {
+        if (s_name.Equals(""))
+        {
+            for (int i = 0; i < currentObsDataList.Count; i++)
+            {
+                currentObsDataList[i].gameObject.SetActive(true);
+            }
+        }
+        else
+        {
+            for (int i = 0; i < currentObsDataList.Count; i++)
+            {
+                currentObsDataList[i].gameObject.SetActive(currentObsDataList[i]._data.name.Contains(s_name));
+            }
+        }
     }
 }