using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; public class SwitchHold : MonoBehaviour { List switcheHoldStatesListNames = new List(); //Dictionary switcheStatesList = new Dictionary(); public Dictionary switcheHoldStatesList = new Dictionary(); // int posCount; // int currentPos; void Start() { // Debug.Log(go.name); Transform[] switchStates = this.GetComponentsInChildren(); // Debug.Log(btnList.Length); for (int i = 0; i < switchStates.Length; i++) { if (i == 0) continue; //Debug.Log(switchStates[i].gameObject.name + " switchStates"); switchStates[i].gameObject.AddComponent(); switcheHoldStatesListNames.Add(switchStates[i].gameObject.name); switcheHoldStatesList.Add(switchStates[i].gameObject.name, switchStates[i].gameObject.GetComponent()); } switcheHoldStatesListNames.Sort(); //Debug.Log(switcheHoldStatesListNames + " switchStates List"); setState(2); } public void setState(int state) { switcheHoldStatesList[switcheHoldStatesListNames[state]].switchOn(); } public void setState(string swName) { switcheHoldStatesList[swName].switchOn(); } /* void OnMouseDown() { Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren(); for (int i = 0; i < btnList.Length; i++) { if (i == 0) continue; btnList[i].gameObject.GetComponent().enabled = false; Debug.Log("btnList[i] + " + btnList[i]); } // Debug.Log(" + " + click); click++; }*/ }