155 lines
5.2 KiB
C#
155 lines
5.2 KiB
C#
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
//#if UNITY_EDITOR
|
|
//using UnityEditor;
|
|
|
|
//[CustomEditor(typeof(Temp_TicketReader)), CanEditMultipleObjects]
|
|
//class TempEditor : Editor
|
|
//{
|
|
// Temp_TicketReader temp;
|
|
|
|
// private void OnEnable()
|
|
// {
|
|
// temp = (Temp_TicketReader)target;
|
|
// }
|
|
|
|
// public override void OnInspectorGUI()
|
|
// {
|
|
// //base.OnInspectorGUI();
|
|
// serializedObject.Update();
|
|
// if (GUI.Button(new Rect(0, 0, 80, 40), new GUIContent("下一步")))
|
|
// {
|
|
// temp.NextStep();
|
|
// }
|
|
// serializedObject.ApplyModifiedProperties();
|
|
// }
|
|
//}
|
|
//#endif
|
|
|
|
public class Temp_TicketReader : MonoBehaviour
|
|
{
|
|
|
|
public string path = Application.streamingAssetsPath + "/操作票/OperqationTicket.json";
|
|
private List<OperationTicketData> ticketDataList;
|
|
List<OperationTicketData> ticketDataList_01 = new List<OperationTicketData>();
|
|
List<OperationTicketData> ticketDataList_02 = new List<OperationTicketData>();
|
|
void Start()
|
|
{
|
|
if (ScenesRecorder.instance == null)
|
|
{
|
|
return;
|
|
}
|
|
ticketDataList_01 = new List<OperationTicketData>();
|
|
ticketDataList_02 = new List<OperationTicketData>();
|
|
// 去空
|
|
foreach (var item in ScenesRecorder.PowerFailure)
|
|
{
|
|
if (string.IsNullOrEmpty(item.Content)) { }
|
|
else
|
|
{
|
|
ticketDataList_01.Add(item);
|
|
}
|
|
}
|
|
foreach (var item in ScenesRecorder.PowerTransmission)
|
|
{
|
|
if (string.IsNullOrEmpty(item.Content)) { }
|
|
else
|
|
{
|
|
ticketDataList_02.Add(item);
|
|
}
|
|
}
|
|
/*
|
|
if (System.IO.File.Exists(path))
|
|
{
|
|
// 读取工作票数据
|
|
string content = System.IO.File.ReadAllText(path);
|
|
JObject jo = JObject.Parse(content);
|
|
ticketDataList = JsonConvert.DeserializeObject<List<OperationTicketData>>(jo["Content"].ToString());
|
|
|
|
////初始化右侧面板
|
|
//ticketLibraryItem = ticketLibraryContent.GetChild(0).gameObject;
|
|
//ticketLibraryItem.gameObject.SetActive(false);
|
|
//for (int i = 1; i < ticketLibraryContent.childCount; i++)
|
|
//{
|
|
// GameObject.DestroyImmediate(ticketLibraryContent.GetChild(i).gameObject);
|
|
//}
|
|
|
|
//// 初始化左侧选中面板
|
|
//ticketParent = ticketSelect_停电.Find("Scroll View/Viewport/Content/Content").transform.GetComponent<RectTransform>();
|
|
//ticketSelectItem = ticketParent.GetChild(0).gameObject;
|
|
//ticketSelectItem.gameObject.SetActive(false);
|
|
////for (int i = 1; i < ticketParent.childCount; i++)
|
|
////{
|
|
//// GameObject.DestroyImmediate(ticketParent.GetChild(i).gameObject);
|
|
////}
|
|
|
|
////ticketSelect_送电.Find("Scroll View/Viewport/Content/Content").GetChild(0).gameObject.SetActive(false);
|
|
////for (int i = 1; i < ticketSelect_送电.Find("Scroll View/Viewport/Content/Content").childCount; i++)
|
|
////{
|
|
//// GameObject.DestroyImmediate(ticketSelect_送电.Find("Scroll View/Viewport/Content/Content").GetChild(i).gameObject);
|
|
////}
|
|
|
|
//// 生成工作票库
|
|
//int no = 0;
|
|
//foreach (var item in ticketDataList)
|
|
//{
|
|
// GameObject go = GameObject.Instantiate<GameObject>(ticketLibraryItem, ticketLibraryContent);
|
|
// go.gameObject.SetActive(true);
|
|
// TictetLibraryItem i = go.GetComponent<TictetLibraryItem>();
|
|
// no++;
|
|
// i.Init(item, no);
|
|
// libraryList.Add(i);
|
|
//}
|
|
////打乱顺序
|
|
//for (int i = 1; i < ticketLibraryContent.childCount; i++)
|
|
//{
|
|
// int sort = UnityEngine.Random.Range(1, ticketLibraryContent.childCount);
|
|
// ticketLibraryContent.GetChild(sort).transform.SetSiblingIndex(1);
|
|
//}
|
|
//for (int n = 1; n < ticketLibraryContent.childCount; n++)
|
|
//{
|
|
// Debug.Log(ticketLibraryContent.GetChild(n));
|
|
// ticketLibraryContent.GetChild(n).GetComponent<TictetLibraryItem>().RefreshSort(n);
|
|
//}
|
|
|
|
// 缓存操作票
|
|
ticketDataList_01 = new List<OperationTicketData>();
|
|
ticketDataList_02 = new List<OperationTicketData>();
|
|
int tmp = 1;
|
|
foreach (var item in ticketDataList)
|
|
{
|
|
if (item.停电顺序 == tmp)
|
|
{
|
|
ticketDataList_01.Add(item);
|
|
}
|
|
if (item.送电顺序 == tmp)
|
|
{
|
|
ticketDataList_02.Add(item);
|
|
}
|
|
tmp++;
|
|
}
|
|
}
|
|
*/
|
|
}
|
|
[ContextMenu("ting")]
|
|
void Ting()
|
|
{
|
|
//ReadTicket.instance.Init(ticketDataList_01);
|
|
}
|
|
[ContextMenu("song")]
|
|
void Song()
|
|
{
|
|
//ReadTicket.instance.Init(ticketDataList_02);
|
|
}
|
|
|
|
[ContextMenu("next")]
|
|
public void NextStep()
|
|
{
|
|
ReadTicket.SwitchNext();
|
|
}
|
|
}
|