mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/MI-38.git
synced 2026-01-24 01:15:41 +03:00
64 lines
2.0 KiB
C#
64 lines
2.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
|
|
public class SwitchHold : MonoBehaviour
|
|
|
|
{
|
|
List<string> switcheHoldStatesListNames = new List<string>();
|
|
//Dictionary<string, GameObject> switcheStatesList = new Dictionary<string, GameObject>();
|
|
public Dictionary<string, SwitchHoldState> switcheHoldStatesList = new Dictionary<string, SwitchHoldState>();
|
|
|
|
// int posCount;
|
|
// int currentPos;
|
|
void Start()
|
|
{
|
|
// Debug.Log(go.name);
|
|
Transform[] switchStates = this.GetComponentsInChildren<Transform>();
|
|
// 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<SwitchHoldState>();
|
|
switcheHoldStatesListNames.Add(switchStates[i].gameObject.name);
|
|
switcheHoldStatesList.Add(switchStates[i].gameObject.name, switchStates[i].gameObject.GetComponent<SwitchHoldState>());
|
|
}
|
|
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<Transform>();
|
|
for (int i = 0; i < btnList.Length; i++)
|
|
{
|
|
if (i == 0) continue;
|
|
|
|
btnList[i].gameObject.GetComponent<SpriteRenderer>().enabled = false;
|
|
Debug.Log("btnList[i] + " + btnList[i]);
|
|
}
|
|
|
|
|
|
|
|
// Debug.Log(" + " + click);
|
|
|
|
click++;
|
|
}*/
|
|
|
|
}
|