Files
MI-38/Heli_with_panels/Assets/Scripts/Panel2D/MyBtnCheck3.cs
2022-07-04 13:15:35 +03:00

51 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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);
}
}