GQ_Communicate/GQ_TongXin/Assets/script/TOOL.cs

71 lines
2.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static DeviceQuery;
public class TOOL : MonoBehaviour
{
public List<GameObject> gameObjects;
// Start is called before the first frame update
[ContextMenu("Start")]
void Start()
{
//Debug.Log(transform.root.Find("对联设备").name);
//GameObject.Instantiate(Resources.Load<GameObject>("古泉站换流站机房/35"));
var dsad = GetComponentInParent<HeatMapFactor>();
Debug.Log(dsad.name + "-------------" + dsad.intensity);
}
// 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);
}
}
}
}
}
}