1
Fork 0
mirror of https://github.com/Steffo99/keep-everything-alive.git synced 2024-11-30 21:14:18 +00:00
keep-everything-alive/Assets/Scripts/Core/UI/DisplayOnly.cs

37 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public enum DisplayOptions {
ALWAYS,
ONLY_DURING_MICROGAMES,
ONLY_DURING_WHEEL,
NEVER
}
public class DisplayOnly : MonoBehaviour
{
public DisplayOptions displayWhen;
private GameController gameController;
private void Awake() {
gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent<GameController>();
}
private void Start() {
gameController.OnMicrogameCreate += OnMicrogameCreate;
gameController.OnMicrogameDestroy += OnMicrogameDestroy;
gameObject.SetActive(displayWhen == DisplayOptions.ALWAYS || displayWhen == DisplayOptions.ONLY_DURING_WHEEL);
}
private void OnMicrogameCreate(MicrogameController microgame) {
gameObject.SetActive(displayWhen == DisplayOptions.ALWAYS || displayWhen == DisplayOptions.ONLY_DURING_MICROGAMES);
}
private void OnMicrogameDestroy(MicrogameController microgame) {
gameObject.SetActive(displayWhen == DisplayOptions.ALWAYS || displayWhen == DisplayOptions.ONLY_DURING_WHEEL);
}
}