using System.Collections; using System.Collections.Generic; using UnityEngine; public class SceneUtil : ActionBase { public Color color01; public Color color02; // 辅助方法,用于初始化图标和相机列表 private void InitializeIconAndCameraLists(string iconName, string cameraName, List iconList, List cameraList, string[] deviceSns, string[] iconNames, string[] identifiers) { iconList.Clear(); cameraList.Clear(); Transform icon = transform.Find(iconName); Transform iconCamera = transform.Find(cameraName); if (icon != null && iconCamera != null) { int count = Mathf.Min(icon.childCount, deviceSns.Length, iconNames.Length); for (int i = 0; i < count; i++) { Transform currentIcon = icon.GetChild(i); Transform currentCamera = iconCamera.GetChild(i); // 获取当前索引对应的设备信息 string deviceSn = deviceSns[i]; string name = iconNames[i]; string identifier = identifiers[i]; // 创建 IconData 实例并添加到 iconList IconData iconData = new IconData(deviceSn, name, identifier, currentIcon, currentCamera.name, currentCamera); iconList.Add(iconData); cameraList.Add(currentCamera); } icon.gameObject.SetActive(false); iconCamera.gameObject.SetActive(false); } } public override void Init() { // 确保 AppCache 中的列表类型为 List if (AppCache.iconPointList01 == null) AppCache.iconPointList01 = new List(); if (AppCache.iconPointList02 == null) AppCache.iconPointList02 = new List(); if (AppCache.iconPointList03 == null) AppCache.iconPointList03 = new List(); if (AppCache.iconPointList04 == null) AppCache.iconPointList04 = new List(); if (AppCache.iconPointList05 == null) AppCache.iconPointList05 = new List(); // 初始化 GNSS 相关列表(12个设备) InitializeIconAndCameraLists("GNSS", "GNSS视角", AppCache.iconPointList01, AppCache.iconCameraList01, new string[] { "MS3P1475041092", "MS3P1475041038", "MS3P1475041023", "MS3P1475041053", "MS3P1475041070", "MS3P1475041068", "MS3P1475041098", "MS3P1475041020", "MS3P1475041030", "MS3P1475041014", "MS3P1475041096", "MS3P1475041084" }, new string[] { "GNSS基准点1", "GNSS监测点1", "GNSS监测点2", "GNSS监测点3", "GNSS监测点4", "GNSS监测点5", "GNSS监测点6", "GNSS监测点7", "GNSS监测点8", "GNSS监测点9", "GNSS监测点10", "GNSS基准点2" }, new string[] { "", "", "", "", "", "", "", "", "", "", "", "" }); // 初始化环境量监测相关列表(1个设备) InitializeIconAndCameraLists("环境量监测", "环境量监测视角", AppCache.iconPointList02, AppCache.iconCameraList02, new string[] { "2025042109" }, new string[] { "环境量监测" }, new string[] { "" }); // 初始化测缝针监测相关列表(9个设备) InitializeIconAndCameraLists("测缝针监测", "测缝计监测视角", AppCache.iconPointList03, AppCache.iconCameraList03, new string[] { "2025042106", "2025042103", "2025042105", "2025042104", "2025042107", "2025042102", "20250421A2", "20250421A1", "2025042101","2025042108" }, new string[] { "测缝计1", "测缝计2", "测缝计3", "测缝计4", "测缝计5", "测缝计6", "测缝计7", "测缝计8", "测缝计9","测缝计10" }, new string[] { "ff01", "ff01", "ff01", "ff01", "ff01", "ff01", "ff01", "ff01", "ff01","ff01" }); // 初始化加速度振动监测相关列表(6个设备) InitializeIconAndCameraLists("加速度振动监测", "加速度振动监测视角", AppCache.iconPointList04, AppCache.iconCameraList04, new string[] { "2025042106", "2025042103", "2025042107", "2025042102", "2025042101", "2025042108" }, new string[] { "振动加速度1", "振动加速度2", "振动加速度3", "振动加速度4", "振动加速度5", "振动加速度6" }, new string[] { "ff03,ff04,ff05", "ff03,ff04,ff05", "ff03,ff04,ff05", "ff03,ff04,ff05", "ff03,ff04,ff05", "ff03,ff04,ff05" }); // 初始化应变计监测相关列表(2个设备) InitializeIconAndCameraLists("应变计监测", "应变计监测视角", AppCache.iconPointList05, AppCache.iconCameraList05, new string[] { "20250421A2", "20250421A1", "20250421A2", "20250421A1", "20250421A2", "20250421A1" }, new string[] { "6号桥墩表面应变监测", "3号桥墩表面应变监测", "5号桥墩表面应变监测", "2号桥墩表面应变监测", "4号桥墩表面应变监测", "1号桥墩表面应变监测" }, new string[] { "ff20,ff21", "ff20,ff21", "ff26,ff27", "ff26,ff27", "ff24,ff25", "ff24,ff25" }); gameObject.SetActive(true); } public override void RegisterAction() { } public override void RemoveAction() { } }