55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class NewBehaviourScript : MonoBehaviour
|
|
{
|
|
public List<Transform> T1_copy;
|
|
public List<Transform> T2_paste;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
[ContextMenu("")]
|
|
public void sad()
|
|
{
|
|
for (int i = 0; i < T1_copy.Count; i++)
|
|
{
|
|
T1_copy[i].position = T2_paste[i].position;
|
|
T1_copy[i].name = T2_paste[i].name;
|
|
if (!T1_copy[i].GetComponent<ModelItem>())
|
|
{
|
|
var a = T1_copy[i].gameObject.AddComponent<ModelItem>();
|
|
UnityEditorInternal.ComponentUtility.CopyComponent(T2_paste[i].GetComponent<ModelItem>());
|
|
UnityEditorInternal.ComponentUtility.PasteComponentValues(a);
|
|
}
|
|
else
|
|
{
|
|
UnityEditorInternal.ComponentUtility.CopyComponent(T2_paste[i].GetComponent<ModelItem>());
|
|
UnityEditorInternal.ComponentUtility.PasteComponentValues(T1_copy[i].GetComponent<ModelItem>());
|
|
}
|
|
}
|
|
}
|
|
|
|
[ContextMenu("ɾ³ýModelItem")]
|
|
public void de()
|
|
{
|
|
for (int i = T2_paste.Count - 1; i >= 0; i--)
|
|
{
|
|
if (T2_paste[i].GetComponent<ModelItem>())
|
|
{
|
|
DestroyImmediate(T2_paste[i].GetComponent<ModelItem>());
|
|
}
|
|
}
|
|
}
|
|
}
|