using System.Collections; using System.Collections.Generic; using UnityEngine; public class Cover : MonoBehaviour { List coverStatesListNames = new List(); //Dictionary switcheStatesList = new Dictionary(); public Dictionary coverStatesList = new Dictionary(); // int posCount; // int currentPos; void Start() { // Debug.Log(go.name); Transform[] coverStates = this.GetComponentsInChildren(); // Debug.Log(btnList.Length); for (int i = 0; i < coverStates.Length; i++) { if (i == 0) continue; // Debug.Log(btnList[i].gameObject.name); coverStates[i].gameObject.AddComponent(); coverStatesListNames.Add(coverStates[i].gameObject.name); coverStatesList.Add(coverStates[i].gameObject.name, coverStates[i].gameObject.GetComponent()); } //coverStatesListNames.Sort(); //setState(0); setState(0); } public void setState(int state) { coverStatesList[coverStatesListNames[state]].switchOn(); } public void setState(string swName) { coverStatesList[swName].switchOn(); } }