This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
project-undercover/Project Undercover/Assets/Scripts/UI/InteractionPanelController.cs

53 lines
No EOL
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class InteractionPanelController : MonoBehaviour {
public Text interactionText;
public GameObject mainPanel;
private static InteractionPanelController activePanel;
void Start()
{
ActivePanel = this;
Hide();
}
public static void Reveal(string interactionText)
{
ActivePanel.interactionText.text = interactionText;
ActivePanel.mainPanel.SetActive(true);
}
public static void Hide()
{
ActivePanel.mainPanel.SetActive(false);
}
public static InteractionPanelController ActivePanel
{
get
{
if (activePanel)
return activePanel;
Debug.LogError("No interaction panels in scene");
return null;
}
set
{
if (!activePanel)
activePanel = value;
else
{
Debug.LogError("More than one interaction panel currently exists in the scene");
}
}
}
public static bool InteractionPrompted()
{
return ActivePanel.mainPanel.activeInHierarchy;
}
}