This commit is contained in:
huangjiayu 2023-11-20 18:01:04 +08:00
parent 830b325713
commit 480b586b21
2 changed files with 125 additions and 0 deletions

View File

@ -0,0 +1,114 @@
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;
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>();
}
[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>();
}
}
[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();
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 08598a3519fbad24195f9a93c4b44600
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: