91 lines
2.6 KiB
C#
91 lines
2.6 KiB
C#
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<GameObject> 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<GameObject>("古泉站换流站机房/35"));
|
|
//port = GetComponent<Dropdown>();
|
|
//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<DeviceQuery>();
|
|
gameObjects[i].name = "R" + (i + 1).ToString().PadLeft(2, '0');
|
|
if (deviceQuery == null)
|
|
{
|
|
var D = gameObjects[i].AddComponent<DeviceQuery>();
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|