Created
November 27, 2021 22:02
-
-
Save pr00thmatic/46d52bd2de8a6ffc94047595f616462e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.UI; | |
using System.Collections; | |
using System.Collections.Generic; | |
public class Dialogue : MonoBehaviour { | |
public static bool isOpen = false; | |
public static Dialogue Instance; | |
public static float timeClosed; | |
[Header("Configuration")] | |
public KeyCode keyToClose = KeyCode.Space; | |
[Header("Initialization")] | |
public Text text; | |
public Animator animator; | |
public static void Open (string message) { | |
Instance.text.text = message; | |
isOpen = true; | |
} | |
void Awake () { | |
Instance = this; | |
} | |
void Update () { | |
if (isOpen && Input.GetKeyDown(keyToClose)) { | |
isOpen = false; | |
timeClosed = Time.time; | |
} | |
animator.SetBool("is open", isOpen); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment