mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/MI-38.git
synced 2026-01-23 23:55:38 +03:00
51 lines
1.4 KiB
C#
51 lines
1.4 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
|
||
public class MyBtnCheck3 : MonoBehaviour
|
||
{
|
||
List<GameObject> buttonStatesList3 = new List<GameObject>();
|
||
int click = 1;
|
||
Manager man;
|
||
|
||
void Start()
|
||
{
|
||
man = GameObject.Find("Manager").GetComponent<Manager>();
|
||
Transform[] buttonStates = this.GetComponentsInChildren<Transform>();
|
||
for (int i = 0; i < buttonStates.Length; i++)
|
||
{
|
||
if (buttonStates[i].name.Length > this.name.Length)
|
||
{
|
||
//Debug.Log(buttonStates[i] + " В массив ");
|
||
buttonStates[i].gameObject.SetActive(false);
|
||
buttonStatesList3.Add(buttonStates[i].gameObject);
|
||
}
|
||
|
||
}
|
||
EnableSprite(click);
|
||
|
||
}
|
||
void OnMouseDown()
|
||
{
|
||
if (man.mode == "scedit" || man.mode == "play")
|
||
return;
|
||
EnableSprite(0);
|
||
}
|
||
void OnMouseUp()
|
||
{
|
||
if (man.mode == "scedit" || man.mode == "play")
|
||
return;
|
||
click++;
|
||
if (click > buttonStatesList3.Count - 1) click = 1;
|
||
//Debug.Log("количество кликов + " + click);
|
||
EnableSprite(click);
|
||
|
||
}
|
||
|
||
public void EnableSprite(int n)
|
||
{
|
||
buttonStatesList3.ForEach(_buttonStatesList3 => _buttonStatesList3.gameObject.SetActive(false));
|
||
buttonStatesList3[n].gameObject.SetActive(true);
|
||
}
|
||
}
|