using System; using System.Collections; using System.Collections.Generic; using Unity.VisualScripting; using UnityEditor.Experimental.GraphView; using UnityEngine; using UnityEngine.UI; using static DeviceQuery; using static GameManager; public class TOOL : MonoBehaviour { public List gameObjects; Dropdown port; // Start is called before the first frame update [ContextMenu("Start")] void Start() { //Debug.Log(transform.root.Find("对联设备").name); //GameObject.Instantiate(Resources.Load("古泉站换流站机房/35")); //port = GetComponent(); //port.onValueChanged.AddListener(OnDropdownValueChanged_port); //for (int i = 0; i < port.options.Count; i++) //{ // if (i == port.value) // { // port.value = i; // } //} //port.value = 0; } private void OnDropdownValueChanged_port(int arg0) { Debug.Log("索引改变为" + arg0); } // Update is called once per frame void Update() { } [ContextMenu("重命名")] public void reName() { if (gameObjects.Count == 0 && gameObjects == null) return; for (int i = 0; i < gameObjects.Count; i++) { var deviceQuery = gameObjects[i].GetComponent(); gameObjects[i].name = "R" + (i + 1).ToString().PadLeft(2, '0'); if (deviceQuery == null) { var D = gameObjects[i].AddComponent(); D.deviceList.deviceCode = gameObjects[i].name; D.deviceList.type = "1"; } else { deviceQuery.deviceList.deviceCode = gameObjects[i].name; deviceQuery.deviceList.type = "1"; } var U = gameObjects[i].transform.Find("U位"); if (U == null) { var go = new GameObject("U位"); go.transform.SetParent(gameObjects[i].transform); for (int j = 0; j < 42; j++) { var g = new GameObject((j + 1).ToString()); g.transform.SetParent(go.transform); } } else { if (U.transform.childCount != 42) { for (int j = 0; j < 42; j++) { var g = new GameObject((j + 1).ToString()); g.transform.SetParent(U.transform); } } } } } }