using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; using System.Linq; using Unity.VisualScripting; using UnityEditor; using UnityEngine; using static BaseConf; public class tooltest : MonoBehaviour { public Transform a; public Transform b; public List A; public List B; public int CardCount = 0; //public class Asd //{ // public string username; // public string password; //} void Start() { //Asd asd = new Asd(); //asd.username = "p6k5b9h9Yfp8Hxf75vO0sA=="; //asd.password = "It8gXWKtH3hA0hLc+q79Lg=="; //var newData = JsonConvert.SerializeObject(asd); //Debug.LogError(CombineJSON.Encrypt(newData)); //Debug.LogError(CombineJSON.Decrypt("9N5AHveJlY8V2XM/4ARv0l/FdyxcgdiaOYJvxcfvxjYt9y2bNfYYoZMzQMmsOObDlavdtLNpurQsOLbE8KlKa2Y4RpBi57Jf7NokVMftviz6kp6ko6OSr6zy82a/6q3ELJPanS7Dv2H9qIQaNespreQ/5E3zsmfTtyokVQncAZLzxpqwkQVGMUutJ21abOqtA46NYZuLgeAtgMDtYiSrbThxf4RrGPcpX2qRo4Bjm32Ys5C5SeZ0Xc1DsuCXqr1ridlQQmYvYnM+ID4c+6Yc/7whrB8R/u/tvrd2AklAnUPtBKVBhtDzqNzo/SemWK9fYPG1jnzt49Urfm97zeb+O5aK8mTP4oycx3JXbWV2lu2qRZ0IhLf5otR6xfaj/aVBc6fFR+/4KwsxQOix0hKcDq5Ew2/Ric1Xhn3BrNRbgKtwr8UHDQy5+40TvYR/4YasFCU7V/EulA5yBPyc4ELK8TQh7hyLWr69bdaean+5HEuF9//BZpwJZ3fhCjbQI0GKo9erXx5ETjcl+bpqqBDYzyCfFklz5PIvIdTOXJC/SIKJaWAMMTLN9Zsfvo9M2Mw0t7qKC7JR0/HvpBRV2fwOxsYBN7j1VvRYsxTNUEKayEmWvluyqO7katNZM06nEkS5F+6N/M1LLtJooVHS+4rWzwdAIC2Q4nxFmKTgSzC8R7OqLoSphTfmttwMx7NVbYhsY5ttyEPUOKJnTxRKrstXJPg4bo5lemyWwX8KTcIkBo+6bX6r/ZgVx7Z07mW3DNHN+3W5uDN1atT8+LUWwk5jRm0gll2USHarUmoHXTyv+jw=")); //Debug.LogError(CombineJSON.Decrypt("9N5AHveJlY8V2XM/4ARv0l/FdyxcgdiaOYJvxcfvxjYt9y2bNfYYoZMzQMmsOObDlavdtLNpurQsOLbE8KlKa2Y4RpBi57Jf7NokVMftviz6kp6ko6OSr6zy82a/6q3ELJPanS7Dv2H9qIQaNespreQ/5E3zsmfTtyokVQncAZLzxpqwkQVGMUutJ21abOqtA46NYZuLgeAtgMDtYiSrbThxf4RrGPcpX2qRo4Bjm32Ys5C5SeZ0Xc1DsuCXqr1ridlQQmYvYnM+ID4c+6Yc/7whrB8R/u/tvrd2AklAnUPtBKVBhtDzqNzo/SemWK9fYPG1jnzt49Urfm97zeb+O5aK8mTP4oycx3JXbWV2lu2qRZ0IhLf5otR6xfaj/aVBc6fFR+/4KwsxQOix0hKcDq5Ew2/Ric1Xhn3BrNRbgKtwr8UHDQy5+40TvYR/4YasFCU7V/EulA5yBPyc4ELK8TQh7hyLWr69bdaean+5HEuF9//BZpwJZ3fhCjbQI0GKo9erXx5ETjcl+bpqqBDYzyCfFklz5PIvIdTOXJC/SIKJaWAMMTLN9Zsfvo9M2Mw0t7qKC7JR0/HvpBRV2fwOxpkJc0u5agKMLha6GPhz3UO1EN+l1TtVryhWvygRrc2LLw4Nr2GAt9yQrtuok9QicjbKwUxi3VGAk9tDrAXPfYFbPYb3BIu7wYtAwzqNRK2DFwKZhJd7X+Tq4jKETZfnFEB4z0iGocoFU2w0+3k+8/9E1sp+IEwUUVrtBGj9zz6G87+HmaLUAUzs/AGHKS3Ssjo9W7xzW1RnmJ2DIaJCsV0=")); } // Update is called once per frame void Update() { } [ContextMenu("粘贴5个脚本(设备)")] public void Replace5() { var b1 = b.AddComponent(); var b2 = b.AddComponent(); var b3 = b.AddComponent(); var b4 = b.AddComponent(); var b5 = b.AddComponent(); UnityEditorInternal.ComponentUtility.CopyComponent(a.GetComponent()); UnityEditorInternal.ComponentUtility.PasteComponentValues(b1); UnityEditorInternal.ComponentUtility.CopyComponent(a.GetComponent()); UnityEditorInternal.ComponentUtility.PasteComponentValues(b2); UnityEditorInternal.ComponentUtility.CopyComponent(a.GetComponent()); UnityEditorInternal.ComponentUtility.PasteComponentValues(b3); UnityEditorInternal.ComponentUtility.CopyComponent(a.GetComponent()); UnityEditorInternal.ComponentUtility.PasteComponentValues(b4); UnityEditorInternal.ComponentUtility.CopyComponent(a.GetComponent()); UnityEditorInternal.ComponentUtility.PasteComponentValues(b5); if (!b.GetComponent()) b.AddComponent(); b.gameObject.layer = 8; } [ContextMenu("-----------------------------------------------------------------")] [ContextMenu("粘贴4个脚本(板卡)")] public void Replace4() { for (int i = 0; i < A.Count; i++) { var b1 = B[i].AddComponent(); //var b2 = B.AddComponent(); var b3 = B[i].AddComponent(); var b4 = B[i].AddComponent(); //var b5 = B.AddComponent(); var b6 = B[i].AddComponent(); UnityEditorInternal.ComponentUtility.CopyComponent(A[i].GetComponent()); UnityEditorInternal.ComponentUtility.PasteComponentValues(b1); //UnityEditorInternal.ComponentUtility.CopyComponent(A.GetComponent()); //UnityEditorInternal.ComponentUtility.PasteComponentValues(b2); UnityEditorInternal.ComponentUtility.CopyComponent(A[i].GetComponent()); UnityEditorInternal.ComponentUtility.PasteComponentValues(b3); UnityEditorInternal.ComponentUtility.CopyComponent(A[i].GetComponent()); UnityEditorInternal.ComponentUtility.PasteComponentValues(b4); //UnityEditorInternal.ComponentUtility.CopyComponent(A.GetComponent()); //UnityEditorInternal.ComponentUtility.PasteComponentValues(b5); UnityEditorInternal.ComponentUtility.CopyComponent(A[i].GetComponent()); UnityEditorInternal.ComponentUtility.PasteComponentValues(b6); if (!B[i].GetComponent()) B[i].AddComponent(); B[i].gameObject.layer = 13; } } [ContextMenu("-----------------------------------------------------------------")] [ContextMenu("粘贴2个脚本(端口)")] public void Replace2() { for (int i = 0; i < A.Count; i++) { PortQuery b1 = B[i].AddComponent(); //var b2= B[i].AddComponent<> UnityEditorInternal.ComponentUtility.CopyComponent(A[i].GetComponent()); UnityEditorInternal.ComponentUtility.PasteComponentValues(b1); B[i].position = A[i].position; B[i].gameObject.layer = 11; B[i].GetComponent().portList.portPosition = (i + 1).ToString(); } } [ContextMenu("端口位置排序")] public void Replace2_() { for (int i = 0; i < B.Count; i++) { var b1 = B[i].GetComponent(); b1.portList.portPosition = (i + 1).ToString(); } } [ContextMenu("-----------------------------------------------------------------")] [ContextMenu("UPosItem批量赋值(机柜)")] public void setUPosItem_c() { var uposi = a.GetComponentsInChildren().ToList(); for (int i = 0; i < uposi.Count; i++) { uposi[i].conf2.isUse = true; uposi[i].conf2.module_type = BaseConf.ModuleType.设备; } } [ContextMenu("-----------------------------------------------------------------")] [ContextMenu("创建新版卡")] public void CreateCards() { for (int i = 0; i < A.Count; i++) { A[i].gameObject.layer = 13; if (!A[i].GetComponent()) { var d = A[i].AddComponent(); d.conf2 = new Conf2(); d.conf2.isUse = true; d.conf2.module_type = ModuleType.板卡; d.conf2.isUseUPostItem = false; d.deviceList.type = "2"; d.deviceList.deviceType = "3"; //d.deviceList.devicePosition = (i + 1).ToString(); } else { var d = A[i].GetComponent(); d.conf2 = new Conf2(); d.conf2.isUse = true; d.conf2.module_type = ModuleType.板卡; d.conf2.isUseUPostItem = false; d.deviceList.type = "2"; d.deviceList.deviceType = "3"; } if (!A[i].GetComponent()) { var t = A[i].AddComponent(); } if (!A[i].GetComponent()) { var c = A[i].AddComponent(); } if (!A[i].GetComponent()) { var m = A[i].AddComponent(); } if (!A[i].GetComponent()) { var dt1 = A[i].AddComponent(); dt1.volume = 1; } else { var dt1 = A[i].GetComponent(); dt1.volume = 1; } A[i].GetComponent().addscript(); } } [ContextMenu("-----------------------------------------------------------------")] [ContextMenu("创建U位")] public void Replace1() { GameObject emptyObject = new GameObject("U位"); emptyObject.layer = 10; emptyObject.transform.parent = b; emptyObject.transform.localPosition = Vector3.zero; emptyObject.transform.localEulerAngles = Vector3.zero; emptyObject.AddComponent(); for (int i = 0; i < A.Count; i++) { GameObject g = new GameObject(); g.layer = 10; g.transform.SetParent(emptyObject.transform); g.transform.localPosition = A[i].localPosition; g.transform.localEulerAngles = A[i].localEulerAngles; g.name = (i + 1).ToString(); var uPosItem = g.AddComponent(); uPosItem.uPosManager = emptyObject.GetComponent(); uPosItem.ID = i + 1; } for (int i = 0; i < A.Count; i++) { var b1 = emptyObject.transform.GetChild(i).AddComponent(); UnityEditorInternal.ComponentUtility.CopyComponent(A[i].GetComponent()); UnityEditorInternal.ComponentUtility.PasteComponentValues(b1); var b2 = emptyObject.transform.GetChild(i).AddComponent(); UnityEditorInternal.ComponentUtility.CopyComponent(A[i].GetComponent()); UnityEditorInternal.ComponentUtility.PasteComponentValues(b2); //A[i].gameObject.SetActive(false); var uposi = emptyObject.transform.GetChild(i).GetComponent(); uposi.conf2 = new BaseConf.Conf2 { isUse = true, module_type = BaseConf.ModuleType.板卡, type_card = Type_Card.类型编号1 }; } AssetDatabase.Refresh();//刷新编辑器 UPosManger uPosManger = emptyObject.GetComponent(); uPosManger.uPosItems = new UPosItem[A.Count]; uPosManger.uPosItems = emptyObject.GetComponentsInChildren(); for (int i = 0; i < A.Count; i++) { A[i].gameObject.SetActive(false); } } //[ContextMenu("赋值位置")] //public void dasdsadsa() //{ // for (int i = 0; i < A.Count; i++) // { // //UnityEditorInternal.ComponentUtility.CopyComponent(A[i].GetComponent()); // //UnityEditorInternal.ComponentUtility.PasteComponentValues(B[i].GetComponent()); // //B[i].name = A[i].name; // A[i].transform.localPosition = new Vector3(-400 + i * 200, 0, 0); // } //} [ContextMenu("生成机柜走线左右小球")] public void createlin() { //for (int i = 0; i < A.Count; i++) //{ // if (A[i].Find("U位")) // { // GameObject emptyObject1 = GameObject.CreatePrimitive(PrimitiveType.Sphere); // GameObject emptyObject2 = GameObject.CreatePrimitive(PrimitiveType.Sphere); // emptyObject1.transform.SetParent(A[i]); // emptyObject2.transform.SetParent(A[i]); // emptyObject1.name = "左"; // emptyObject2.name = "右"; // emptyObject1.transform.localPosition = new Vector3(0.391f, 0.31f, 1.1585f); // emptyObject2.transform.localPosition = new Vector3(0.391f, -0.31f, 1.1585f); // emptyObject1.transform.localScale = 0.01f * Vector3.one; // emptyObject2.transform.localScale = 0.01f * Vector3.one; // B.Add(emptyObject1.transform); // B.Add(emptyObject2.transform); // } //} for (int i = 0; i < B.Count; i++) { B[i].gameObject.SetActive(false); } } }