| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Sirenix.OdinInspector;
- using System;
- using UnityCommon;
- namespace DTYJ
- {
- public class TvmCtrl : SerializedMonoBehaviour
- {
- public static TvmCtrl Instance;
- public Material mt_0, mt_1, mt_2;
- public Dictionary<string, GameObject> map = new Dictionary<string, GameObject>();
- private void Awake()
- {
- Instance = this;
- }
- [Serializable]
- public class TvmItem
- {
- }
- public void SetTVM(string id, int state)
- {
- if (map.ContainsKey(id))
- SetState(map[id], state);
- }
- /// <summary>
- /// 0Õý³£
- /// 1ÔÝÍ£
- /// </summary>
- /// <param name="state"></param>
- public void SetState(GameObject goRoot, int state)
- {
- Material mat = null;
- switch (state)
- {
- case 0:
- mat = mt_0;
- break;
- case 1:
- mat = mt_1;
- break;
- case 2:
- mat = mt_2;
- break;
- }
- goRoot.transform.GetChild(11).GetComponent<MeshRenderer>().material = mat;
- goRoot.transform.GetChild(13).GetComponent<MeshRenderer>().material = mat;
- goRoot.transform.GetChild(19).GetComponent<MeshRenderer>().material = mat;
- goRoot.transform.GetChild(21).GetComponent<MeshRenderer>().material = mat;
- goRoot.transform.GetChild(22).GetComponent<MeshRenderer>().material = mat;
- }
- [ContextMenu("´¦Àí")]
- public void HandleTemp()
- {
- Dictionary<string, GameObject> mapNew = new Dictionary<string, GameObject>();
- foreach (var kvp in map)
- {
- var goPath = Utility.GetPathInHierichy(kvp.Value.transform, null);
- mapNew["1_" + kvp.Key] = GameObject.Find("StationOthers/1/" + goPath);
- mapNew["2_" + kvp.Key] = GameObject.Find("StationOthers/2/" + goPath);
- }
- foreach (var kvp in mapNew)
- {
- map[kvp.Key] = kvp.Value;
- }
- }
- }
- }
|