mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/MI-38.git
synced 2026-01-24 02:45:39 +03:00
04.07.2022
This commit is contained in:
63
Heli_with_panels/Assets/Scripts/Panel2D/SwitchHold.cs
Normal file
63
Heli_with_panels/Assets/Scripts/Panel2D/SwitchHold.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
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++;
|
||||
}*/
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user