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

38 lines
1.1 KiB
C#
Raw Normal View History

2020-04-18 20:45:36 +00:00
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);
}
}