using UnityEngine; using System.IO; public class NotesController : MonoBehaviour { public TextAsset note; public TextReaderController textReader; public Canvas uiCanvas; public GameObject Player; public bool enabled = false; public bool inNote = false; // Use this for initialization void Start () { textReader = GameObject.FindGameObjectWithTag("TextReader").GetComponent(); uiCanvas = GameObject.FindGameObjectWithTag("TextReader").GetComponent(); } // Update is called once per frame void Update () { Player = GameObject.FindGameObjectWithTag("Player"); if (enabled) { Player.GetComponent().enabled = false; Time.timeScale = 0; uiCanvas.enabled = true; textReader.note = note; } else { uiCanvas.enabled = false; Time.timeScale = 1; Player.GetComponent().enabled = true; } if (inNote == true && Input.GetKeyDown(KeyCode.Q)) { enabled = !enabled; } } private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "Player") { inNote = true; } } private void OnTriggerExit2D(Collider2D collision) { if (collision.gameObject.tag == "Player") { inNote = false; } } }