GQ_Communicate/GQ_URP/GQ/Assets/tooltest.cs

139 lines
5.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
public class tooltest : MonoBehaviour
{
public Transform a;
public Transform b;
public List<Transform> A;
public List<Transform> B;
public int CardCount = 0;
void Start()
{
}
// Update is called once per frame
void Update()
{
}
[ContextMenu("粘贴5个脚本设备")]
public void Replace5()
{
var b1 = b.AddComponent<DeviceQuery>();
var b2 = b.AddComponent<DragTest>();
var b3 = b.AddComponent<TmsAlarmQuery>();
var b4 = b.AddComponent<TransparentGlow>();
var b5 = b.AddComponent<DragTest1>();
UnityEditorInternal.ComponentUtility.CopyComponent(a.GetComponent<DeviceQuery>());
UnityEditorInternal.ComponentUtility.PasteComponentValues(b1);
UnityEditorInternal.ComponentUtility.CopyComponent(a.GetComponent<DragTest>());
UnityEditorInternal.ComponentUtility.PasteComponentValues(b2);
UnityEditorInternal.ComponentUtility.CopyComponent(a.GetComponent<TmsAlarmQuery>());
UnityEditorInternal.ComponentUtility.PasteComponentValues(b3);
UnityEditorInternal.ComponentUtility.CopyComponent(a.GetComponent<TransparentGlow>());
UnityEditorInternal.ComponentUtility.PasteComponentValues(b4);
UnityEditorInternal.ComponentUtility.CopyComponent(a.GetComponent<DragTest1>());
UnityEditorInternal.ComponentUtility.PasteComponentValues(b5);
if (!b.GetComponent<MeshCollider>()) b.AddComponent<MeshCollider>();
b.gameObject.layer = 8;
}
[ContextMenu("-----------------------------------------------------------------")]
[ContextMenu("粘贴4个脚本板卡")]
public void Replace4()
{
for (int i = 0; i < A.Count; i++)
{
var b1 = B[i].AddComponent<DeviceQuery>();
//var b2 = B.AddComponent<DragTest>();
var b3 = B[i].AddComponent<TmsAlarmQuery>();
var b4 = B[i].AddComponent<TransparentGlow>();
//var b5 = B.AddComponent<DragTest1>();
var b6 = B[i].AddComponent<ClickEvent>();
UnityEditorInternal.ComponentUtility.CopyComponent(A[i].GetComponent<DeviceQuery>());
UnityEditorInternal.ComponentUtility.PasteComponentValues(b1);
//UnityEditorInternal.ComponentUtility.CopyComponent(A.GetComponent<DragTest>());
//UnityEditorInternal.ComponentUtility.PasteComponentValues(b2);
UnityEditorInternal.ComponentUtility.CopyComponent(A[i].GetComponent<TmsAlarmQuery>());
UnityEditorInternal.ComponentUtility.PasteComponentValues(b3);
UnityEditorInternal.ComponentUtility.CopyComponent(A[i].GetComponent<TransparentGlow>());
UnityEditorInternal.ComponentUtility.PasteComponentValues(b4);
//UnityEditorInternal.ComponentUtility.CopyComponent(A.GetComponent<DragTest1>());
//UnityEditorInternal.ComponentUtility.PasteComponentValues(b5);
UnityEditorInternal.ComponentUtility.CopyComponent(A[i].GetComponent<ClickEvent>());
UnityEditorInternal.ComponentUtility.PasteComponentValues(b6);
if (!B[i].GetComponent<MeshCollider>()) B[i].AddComponent<MeshCollider>();
B[i].gameObject.layer = 13;
}
}
[ContextMenu("-----------------------------------------------------------------")]
[ContextMenu("粘贴2个脚本端口")]
public void Replace2()
{
for (int i = 0; i < A.Count; i++)
{
PortQuery b1 = B[i].AddComponent<PortQuery>();
//var b2= B[i].AddComponent<>
UnityEditorInternal.ComponentUtility.CopyComponent(A[i].GetComponent<PortQuery>());
UnityEditorInternal.ComponentUtility.PasteComponentValues(b1);
B[i].position = A[i].position;
B[i].gameObject.layer = 11;
B[i].GetComponent<PortQuery>().portList.portPosition = (i + 1).ToString();
}
}
[ContextMenu("端口位置排序")]
public void Replace2_()
{
for (int i = 0; i < B.Count; i++)
{
var b1 = B[i].GetComponent<PortQuery>();
b1.portList.portPosition = (i + 1).ToString();
}
}
[ContextMenu("-----------------------------------------------------------------")]
[ContextMenu("创建U位")]
public void Replace1()
{
GameObject emptyObject = new GameObject("U位");
emptyObject.transform.parent = b;
emptyObject.transform.localPosition = Vector3.zero;
emptyObject.transform.localEulerAngles = Vector3.zero;
emptyObject.AddComponent<UPosManger>();
for (int i = 0; i < CardCount; i++)
{
GameObject g = new GameObject();
g.transform.parent = emptyObject.transform;
g.transform.localPosition = Vector3.zero;
g.transform.localEulerAngles = Vector3.zero;
g.name = (i + 1).ToString();
g.AddComponent<UPosItem>();
}
}
}