using System.Collections; using System.Collections.Generic; using UnityEngine; public class NewBehaviourScript : MonoBehaviour { public List T1_copy; public List 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()) { var a = T1_copy[i].gameObject.AddComponent(); UnityEditorInternal.ComponentUtility.CopyComponent(T2_paste[i].GetComponent()); UnityEditorInternal.ComponentUtility.PasteComponentValues(a); } else { UnityEditorInternal.ComponentUtility.CopyComponent(T2_paste[i].GetComponent()); UnityEditorInternal.ComponentUtility.PasteComponentValues(T1_copy[i].GetComponent()); } } } [ContextMenu("ɾ³ýModelItem")] public void de() { for (int i = T2_paste.Count - 1; i >= 0; i--) { if (T2_paste[i].GetComponent()) { DestroyImmediate(T2_paste[i].GetComponent()); } } } }