using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; using System.IO; public class ConsoleController : MonoBehaviour { public bool isActive; public InputField CommandText; public Text Text; public Camera mainCamera; void Awake() { DontDestroyOnLoad(gameObject); } // Use this for initialization void Start () { this.GetComponent().enabled = false; isActive = false; } // Update is called once per frame void Update () { mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent(); this.GetComponent().worldCamera = mainCamera; this.transform.position = new Vector3(mainCamera.transform.position.x-1,mainCamera.transform.position.y-1,90); if (Input.GetKeyDown(KeyCode.Period)) { isActive = !isActive; Cursor.visible = isActive; } if(isActive){ //Time.timeScale = 0; } else { //Time.timeScale = 1; } this.GetComponent().enabled = isActive; } public void Command() { switch (CommandText.text.ToString()) { case "Quit": Application.Quit(); break; case "Reload": Text.text += ("\n Reloading"); SceneManager.LoadScene("InterStage",LoadSceneMode.Single); break; case "Delete saves": if (File.Exists(Application.persistentDataPath + "/UpStairs.sav")) { Text.text += ("\n Deleting saved data"); File.Delete(Application.persistentDataPath + "/UpStairs.sav"); Text.text += ("\n Reloading"); SceneManager.LoadScene("InterStage", LoadSceneMode.Single); } else { Text.text += ("\n Can't find any data file"); } break; default: Text.text += ("\n Can't understand " + CommandText.text.ToString()); break; } } }