41 lines
1.0 KiB
C#
41 lines
1.0 KiB
C#
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
public class EnableMenuSript : MonoBehaviour
|
|
{
|
|
[SerializeField] private GameObject _Menu;
|
|
[SerializeField] private Button[] _Button = new Button[2];
|
|
|
|
public void EnableMenu()
|
|
{
|
|
if (_Menu.activeSelf)
|
|
{
|
|
_Menu.SetActive(false);
|
|
Time.timeScale = 1f;
|
|
}
|
|
else
|
|
{
|
|
GameObject selectedObject = EventSystem.current.currentSelectedGameObject;
|
|
|
|
// Ïðîâåðÿåì, åñëè âûáðàííûé îáúåêò ñóùåñòâóåò
|
|
if (selectedObject != null)
|
|
{
|
|
// Åñëè ýòî êíîïêà, ìîæåì ïîëó÷èòü êîìïîíåíò Button
|
|
Button selectedButton = selectedObject.GetComponent<Button>();
|
|
|
|
if (selectedButton != null)
|
|
{
|
|
selectedButton.GetComponent<Image>().color = Color.white;
|
|
}
|
|
}
|
|
|
|
_Menu.SetActive(true);
|
|
_Button[0].Select();
|
|
Time.timeScale = 0f;
|
|
|
|
}
|
|
}
|
|
|
|
}
|