mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/MI-38.git
synced 2026-01-24 00:15:39 +03:00
04.07.2022
This commit is contained in:
97
Heli_with_panels/Assets/Scripts/Panel2D/Switch.cs
Normal file
97
Heli_with_panels/Assets/Scripts/Panel2D/Switch.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
<<<<<<< HEAD
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Switch : MonoBehaviour
|
||||
{
|
||||
List<string> switcheStatesListNames = new List<string>();
|
||||
//Dictionary<string, GameObject> switcheStatesList = new Dictionary<string, GameObject>();
|
||||
public Dictionary<string, SwitchState> switcheStatesList = new Dictionary<string, SwitchState>();
|
||||
bool isStarted = false;
|
||||
|
||||
// int posCount;
|
||||
// int currentPos;
|
||||
void Start()
|
||||
{
|
||||
if (isStarted) return;
|
||||
// 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(btnList[i].gameObject.name);
|
||||
switchStates[i].gameObject.AddComponent<SwitchState>();
|
||||
switcheStatesListNames.Add(switchStates[i].gameObject.name);
|
||||
switcheStatesList.Add(switchStates[i].gameObject.name, switchStates[i].gameObject.GetComponent<SwitchState>());
|
||||
}
|
||||
switcheStatesListNames.Sort();
|
||||
if(switcheStatesListNames.Count>0)
|
||||
switcheStatesList[switcheStatesListNames[0]].switchOn();
|
||||
isStarted = true;
|
||||
//setState(1);
|
||||
}
|
||||
|
||||
public void setState(int state)
|
||||
{
|
||||
if (!isStarted) Start();
|
||||
if (state >= 0 && state < switcheStatesListNames.Count)
|
||||
switcheStatesList[switcheStatesListNames[state]].switchOn();
|
||||
else
|
||||
Debug.LogError("Ошибка установки состояния " + state + " объекта " + this.gameObject.name);
|
||||
}
|
||||
public void setState(string swName)
|
||||
{
|
||||
if (!isStarted) Start();
|
||||
switcheStatesList[swName].switchOn();
|
||||
}
|
||||
}
|
||||
=======
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Switch : MonoBehaviour
|
||||
{
|
||||
List<string> switcheStatesListNames = new List<string>();
|
||||
//Dictionary<string, GameObject> switcheStatesList = new Dictionary<string, GameObject>();
|
||||
public Dictionary<string, SwitchState> switcheStatesList = new Dictionary<string, SwitchState>();
|
||||
bool isStarted = false;
|
||||
|
||||
// int posCount;
|
||||
// int currentPos;
|
||||
void Start()
|
||||
{
|
||||
if (isStarted) return;
|
||||
// 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(btnList[i].gameObject.name);
|
||||
switchStates[i].gameObject.AddComponent<SwitchState>();
|
||||
switcheStatesListNames.Add(switchStates[i].gameObject.name);
|
||||
switcheStatesList.Add(switchStates[i].gameObject.name, switchStates[i].gameObject.GetComponent<SwitchState>());
|
||||
}
|
||||
switcheStatesListNames.Sort();
|
||||
if(switcheStatesListNames.Count>0)
|
||||
switcheStatesList[switcheStatesListNames[0]].switchOn();
|
||||
isStarted = true;
|
||||
//setState(1);
|
||||
}
|
||||
|
||||
public void setState(int state)
|
||||
{
|
||||
if (!isStarted) Start();
|
||||
if (state >= 0 && state < switcheStatesListNames.Count)
|
||||
switcheStatesList[switcheStatesListNames[state]].switchOn();
|
||||
else
|
||||
Debug.LogError("Ошибка установки состояния " + state + " объекта " + this.gameObject.name);
|
||||
}
|
||||
public void setState(string swName)
|
||||
{
|
||||
if (!isStarted) Start();
|
||||
switcheStatesList[swName].switchOn();
|
||||
}
|
||||
}
|
||||
>>>>>>> 3b1b9479a46e90d056b92897ea9f8422b25fc052
|
||||
Reference in New Issue
Block a user