GQ_Communicate/GQ_VR/Assets/Editor/tooltest.cs

425 lines
16 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 BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Unity.VisualScripting;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
using static BaseConf;
public class tooltest : MonoBehaviour
{
public SearchData searchData;
public Transform a;
public Transform b;
public List<Transform> A;
public List<Transform> 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/SIKJaWA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Ssjo9W7xzW1RnmJ2DIaJCsV0="));
}
// Update is called once per frame
void Update()
{
}
[ContextMenu("ճ<><D5B3>5<EFBFBD><35><EFBFBD>ű<EFBFBD><C5B1><EFBFBD><EFBFBD><EFBFBD><E8B1B8>")]
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("ճ<><D5B3>4<EFBFBD><34><EFBFBD>ű<EFBFBD><C5B1><EFBFBD><EFBFBD><EFBFBD><E5BFA8>")]
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("ճ<><D5B3>2<EFBFBD><32><EFBFBD>ű<EFBFBD><C5B1><EFBFBD><EFBFBD>˿ڣ<CBBF>")]
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("<22>˿<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")]
public void Replace2_()
{
for (int i = 0; i < B.Count; i++)
{
//PortQuery b1 = B[i].GetComponent<PortQuery>();
//if (b1)
//{
// b1.portList.portPosition = (i + 1).ToString();
// b1.portList.status = "1";
//}
//else
//{
// b1 = B[i].AddComponent<PortQuery>();
// b1.portList.portPosition = (i + 1).ToString();
// b1.portList.status = "1";
//}
//B[i].gameObject.layer = 11;
//B[i].name = (i + 999).ToString();
//if (i == 0) { B[i].name = "102"; }
B[i].GetComponent<Image>().sprite = Resources.Load<Sprite>("<22><EFBFBD><E8B1B8><EFBFBD><EFBFBD>ͼ/" + B[i].name);
}
}
[ContextMenu("-----------------------------------------------------------------")]
[ContextMenu("UPosItem<65><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")]
public void setUPosItem_c()
{
var uposi = a.GetComponentsInChildren<UPosItem>().ToList();
for (int i = 0; i < uposi.Count; i++)
{
uposi[i].conf2.isUse = true;
uposi[i].conf2.module_type = BaseConf.ModuleType.<EFBFBD>;
}
}
[ContextMenu("-----------------------------------------------------------------")]
[ContextMenu("<22><><EFBFBD><EFBFBD><EFBFBD>°濨")]
public void CreateCards()
{
for (int i = 0; i < A.Count; i++)
{
A[i].gameObject.layer = 13;
if (!A[i].GetComponent<DeviceQuery>())
{
var d = A[i].AddComponent<DeviceQuery>();
d.conf2 = new Conf2();
d.conf2.isUse = true;
d.conf2.module_type = ModuleType.<EFBFBD>;
d.conf2.isUseUPostItem = false;
d.deviceList.type = "2";
d.deviceList.deviceType = "3";
//d.deviceList.devicePosition = (i + 1).ToString();
}
else
{
var d = A[i].GetComponent<DeviceQuery>();
d.conf2 = new Conf2();
d.conf2.isUse = true;
d.conf2.module_type = ModuleType.<EFBFBD>;
d.conf2.isUseUPostItem = false;
d.deviceList.type = "2";
d.deviceList.deviceType = "3";
}
if (!A[i].GetComponent<TmsAlarmQuery>())
{
var t = A[i].AddComponent<TmsAlarmQuery>();
}
if (!A[i].GetComponent<ClickEvent>())
{
var c = A[i].AddComponent<ClickEvent>();
}
if (!A[i].GetComponent<MeshCollider>())
{
var m = A[i].AddComponent<MeshCollider>();
}
if (!A[i].GetComponent<DragTest1>())
{
var dt1 = A[i].AddComponent<DragTest1>();
dt1.volume = 1;
}
else
{
var dt1 = A[i].GetComponent<DragTest1>();
dt1.volume = 1;
}
A[i].GetComponent<DeviceQuery>().addscript();
}
}
[ContextMenu("-----------------------------------------------------------------")]
[ContextMenu("<22><><EFBFBD><EFBFBD>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<UPosManger>();
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>();
uPosItem.uPosManager = emptyObject.GetComponent<UPosManger>();
uPosItem.ID = i + 1;
}
for (int i = 0; i < A.Count; i++)
{
var b1 = emptyObject.transform.GetChild(i).AddComponent<MeshFilter>();
UnityEditorInternal.ComponentUtility.CopyComponent(A[i].GetComponent<MeshFilter>());
UnityEditorInternal.ComponentUtility.PasteComponentValues(b1);
var b2 = emptyObject.transform.GetChild(i).AddComponent<MeshCollider>();
UnityEditorInternal.ComponentUtility.CopyComponent(A[i].GetComponent<MeshFilter>());
UnityEditorInternal.ComponentUtility.PasteComponentValues(b2);
//A[i].gameObject.SetActive(false);
var uposi = emptyObject.transform.GetChild(i).GetComponent<UPosItem>();
uposi.conf2 = new BaseConf.Conf2
{
isUse = true,
module_type = BaseConf.ModuleType.<EFBFBD>,
type_card = Type_Card.<EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><EFBFBD><EFBFBD>1
};
}
AssetDatabase.Refresh();//ˢ<>±༭<C2B1><E0BCAD>
UPosManger uPosManger = emptyObject.GetComponent<UPosManger>();
uPosManger.uPosItems = new UPosItem[A.Count];
uPosManger.uPosItems = emptyObject.GetComponentsInChildren<UPosItem>();
for (int i = 0; i < A.Count; i++)
{
A[i].gameObject.SetActive(false);
}
}
//[ContextMenu("<22><>ֵλ<D6B5><CEBB>")]
//public void dasdsadsa()
//{
// for (int i = 0; i < A.Count; i++)
// {
// //UnityEditorInternal.ComponentUtility.CopyComponent(A[i].GetComponent<RectTransform>());
// //UnityEditorInternal.ComponentUtility.PasteComponentValues(B[i].GetComponent<RectTransform>());
// //B[i].name = A[i].name;
// A[i].transform.localPosition = new Vector3(-400 + i * 200, 0, 0);
// }
//}
//[ContextMenu("<22><><EFBFBD>ɻ<EFBFBD><C9BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1>")]
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 = "<22><>";
// emptyObject2.name = "<22><>";
// 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); }
}
[ContextMenu("<22><>ֵ<EFBFBD><D6B5>ת<EFBFBD>˵<EFBFBD>")]
public void dasdsa()
{
for (int i = 0; i < A.Count; i++)
{
B[i].GetComponent<DragController>().oriObjectPrefab = A[i].GetComponent<DragTest1>();
}
}
[ContextMenu("<22><><EFBFBD>ݵ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>")]
public void sdasd()
{
var l = b.GetComponent<LineRenderer>();
l.positionCount = B.Count;
for (int i = 0; i < B.Count; i++)
{
l.SetPosition(i, B[i].position);
}
}
[ContextMenu("<22><>ת<EFBFBD>˵<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ֵDragTest1")]
public void czxc()
{
string folderPath = Application.dataPath + "/Resources/<2F><>Ȫվ<C8AA><D5BE><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>90<39><30><EFBFBD>ͺ<EFBFBD>"; // <20>滻YourFolderPathΪ<68><CEAA><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>·<EFBFBD><C2B7>
string[] filePaths = Directory.GetFiles(folderPath, "*.*", SearchOption.AllDirectories);
Object[] files = Resources.LoadAll("<22><>Ȫվ<C8AA><D5BE><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>90<39><30><EFBFBD>ͺ<EFBFBD>");
var sortedObjects = files.OrderBy(obj => int.Parse(obj.name)).ToArray();
if (files.Length > 0)
{
for (int i = 0; i < B.Count; i++)
{
Object desiredFile = sortedObjects[i];
GameObject game = desiredFile as GameObject;
//GameObject game= Resources.Load()
B[i].GetComponent<DragController>().oriObjectPrefab = game.GetComponent<DragTest1>();
}
}
}
[ContextMenu("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>")]
public void setw()
{
for (int i = 1; i < B.Count; i++)
{
B[i].localPosition = new Vector3(B[0].localPosition.x + i * 200, 0, 0);
}
}
[ContextMenu("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>Ӳ˵<D3B2><CBB5><EFBFBD>ȡ<EFBFBD><C8A1>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>")]
public void getMenuName()
{
if (searchData != null)
{
for (int i = 0; i < B.Count; i++)
{
//var v = searchData.deviceCards.FindIndex(x => x.Num == (B[i].name));
var v = searchData.devices.FindIndex(x => x.ID == (B[i].name));
if (v == -1)
{
continue;
}
//B[i].GetChild(1).GetComponent<Text>().text = searchData.deviceCards[v].Num + "-" + searchData.deviceCards[v].deviceName + "\n" + searchData.deviceCards[v].manufacturer + "-" + searchData.deviceCards[v].deviceType;
B[i].GetChild(1).GetComponent<Text>().text = searchData.devices[v].ID + "-" + searchData.devices[v].manufacturer + "\n" + searchData.devices[v].deviceType + "-" + searchData.devices[v].deviceNum;
}
}
}
public LineRenderer lineRenderer;
[ContextMenu("ͳһ<CDB3>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µײ<C2B5>")]
public void dsadsad()
{
lineRenderer = GetComponent<LineRenderer>();
if (!lineRenderer)
return;
var pos = lineRenderer.GetPosition(0);
InsertPoint(0, new Vector3(pos.x, 0.06372298f, pos.z));
}
void InsertPoint(int index, Vector3 newPosition)
{
// <20><><EFBFBD><EFBFBD><EFBFBD>߶εĵ<CEB5><C4B5><EFBFBD>
lineRenderer.positionCount++;
// <20><><EFBFBD>κ<EFBFBD><CEBA>ƺ<EFBFBD><C6BA><EFBFBD><EFBFBD>ĵ<EFBFBD>
for (int i = lineRenderer.positionCount - 1; i > index; i--)
{
lineRenderer.SetPosition(i, lineRenderer.GetPosition(i - 1));
}
// <20><>ָ<EFBFBD><D6B8>λ<EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD>µĵ<C2B5>
lineRenderer.SetPosition(index, newPosition);
}
}