| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 | 
							- using System;
 
- using System.Collections;
 
- using System.Collections.Generic;
 
- using System.IO;
 
- using System.Linq;
 
- using UnityEngine;
 
- using UnityEditor;
 
- using Object = UnityEngine.Object;
 
- public class DevicesTargetCreat : EditorWindow
 
- {
 
-     public Transform creatContent;
 
-     public Object jsonFile;
 
-     public Vector3 creatPos;
 
-     
 
-     
 
-     [MenuItem("Plugins/DevicesTargetCreat")]
 
-     static void Init()
 
-     {
 
-         DevicesTargetCreat DevicesTargetCreatTool = EditorWindow.CreateWindow<DevicesTargetCreat>();
 
-         DevicesTargetCreatTool.Show();
 
-     }
 
-     public void OnGUI()
 
-     {
 
-         creatContent = (Transform)EditorGUILayout.ObjectField("容器", creatContent, typeof(Transform), true);
 
-         creatPos=EditorGUILayout.Vector3Field("生成坐标", creatPos);
 
-         jsonFile = Selection.activeObject;
 
-         EditorGUILayout.LabelField("选中文件:");
 
-         EditorGUILayout.ObjectField(jsonFile, typeof(Object));
 
-         if (GUILayout.Button("生成参照物"))
 
-         {
 
-             if (jsonFile == null)
 
-             {
 
-                 Debug.LogError("没选择Json!");
 
-                 return;
 
-             }
 
-             string jsonStr = File.ReadAllText(AssetDatabase.GetAssetPath(jsonFile));
 
-             SensorListResult tempData = JsonUtility.FromJson<SensorListResult>(jsonStr);
 
-             foreach (var t in tempData.rows)
 
-             {
 
-                 //手动过滤下 套口 补元
 
-                 if (t.stationName.Equals("套口")||!t.sensorType.Equals("温度"))
 
-                 {
 
-                     continue;
 
-                 }
 
-                 GameObject creatObj = new GameObject();
 
-                 creatObj.transform.SetParent(creatContent);
 
-                 creatObj.transform.localPosition = creatPos;
 
-                 string nameHead = "";
 
-                 if (t.stationName.Equals("补元"))
 
-                 {
 
-                     nameHead = "BY_";
 
-                 }
 
-                 else
 
-                 {
 
-                     nameHead = "TK_";
 
-                 }
 
-                 creatObj.name = $"{nameHead}{t.sensorName}";
 
-                 creatObj.tag = "DeviceIconTarget";
 
-             }
 
-         }
 
-     }
 
- }
 
- [Serializable]
 
- public class SensorListResult
 
- {
 
-     public int total;
 
-     public List<DevicesId_Data> rows;
 
- }
 
- [Serializable]
 
- public class DevicesId_Data
 
- {
 
-     public string sid;
 
-     public string stationName;//站点名称?
 
-     public string sensorName;
 
-     public string sensorType;//设备类型?
 
-     public string valueType1;//单位
 
-     public string valueType2;
 
-     
 
-     public string dataSid;
 
-     public string dataGid;
 
-     public float realtimeValue1;
 
-     public string realtimeValue2;
 
-     public string dataUpdateTime;
 
-     public string groupId;
 
-     public string groupName;
 
- }
 
 
  |