Unity_1lab/1 laba/Assets/Scripts/UIManager.cs

31 lines
818 B
C#

using UnityEngine;
using TMPro;
public class UIManager : MonoBehaviour
{
public static UIManager Instance; // Singleton
[Header("UI Elements (TextMeshProUGUI äëÿ öèôð)")]
public TextMeshProUGUI[] noteTexts; // Ìàññèâ èç 4 òåêñòîâ (NoteText1, NoteText2, etc.)
private void Awake()
{
if (Instance == null) Instance = this;
else Destroy(gameObject);
}
public void DisplayNote(int index, char digit)
{
if (index >= 1 && index <= noteTexts.Length)
{
noteTexts[index - 1].text = digit.ToString(); // Îòîáðàæàåì öèôðó â ñîîòâåòñòâóþùåì ñëîòå
noteTexts[index - 1].gameObject.SetActive(true); // Àêòèâèðóåì, åñëè áûë ñêðûò
}
else
{
Debug.LogError("Invalid note index: " + index);
}
}
}