Skip to content

Instantly share code, notes, and snippets.

@pr00thmatic
Created November 27, 2021 22:02
Show Gist options
  • Save pr00thmatic/46d52bd2de8a6ffc94047595f616462e to your computer and use it in GitHub Desktop.
Save pr00thmatic/46d52bd2de8a6ffc94047595f616462e to your computer and use it in GitHub Desktop.
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