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 map = new Dictionary(); private void Awake() { Instance = this; } [Serializable] public class TvmItem { } public void SetTVM(string id, int state) { if (map.ContainsKey(id)) SetState(map[id], state); } /// /// 0Õý³£ /// 1ÔÝÍ£ /// /// 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().material = mat; goRoot.transform.GetChild(13).GetComponent().material = mat; goRoot.transform.GetChild(19).GetComponent().material = mat; goRoot.transform.GetChild(21).GetComponent().material = mat; goRoot.transform.GetChild(22).GetComponent().material = mat; } [ContextMenu("´¦Àí")] public void HandleTemp() { Dictionary mapNew = new Dictionary(); 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; } } } }