89 lines
2.2 KiB
C#
89 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class TOOL : MonoBehaviour
|
|
{
|
|
public List<GameObject> gameObjects;
|
|
|
|
|
|
public string port;
|
|
public string deviceId;
|
|
public string conDevice;
|
|
public string conPort;
|
|
|
|
|
|
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
[ContextMenu("寻找物体组")]
|
|
public void das()
|
|
{
|
|
GameManager.Inst.FindPortPos();
|
|
}
|
|
}
|