From 593f1ca9f84e70970c0bdb1e3f73b5b6340ef47a Mon Sep 17 00:00:00 2001 From: excitedneon Date: Mon, 8 May 2017 04:16:01 +0300 Subject: [PATCH] Moved DebugConsole initialization to the ctr to enable printing in Starts. --- Assets/Scripts/Console/DebugConsole.cs | 68 +++++++++++++------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/Assets/Scripts/Console/DebugConsole.cs b/Assets/Scripts/Console/DebugConsole.cs index 5929f10..8c9f5d1 100644 --- a/Assets/Scripts/Console/DebugConsole.cs +++ b/Assets/Scripts/Console/DebugConsole.cs @@ -14,6 +14,40 @@ public class DebugConsole : MonoBehaviour { private Dictionary Actions = new Dictionary(); + public DebugConsole() { + AddCommand("help", "Lists all commands.", (args) => { + Println("Commands:"); + foreach (string Action in Actions.Keys) { + Println("- " + Action); + } + }); + + AddCommand("help (command)", "Describes the given command.", (args) => { + // Check complete versions of the names (so you can do eg. help "help (command)") + foreach (string Action in Actions.Keys) { + if (Action.Equals(args[0])) { + Println(Actions[Action].Description); + return; + } + } + // Check just names + foreach (string Action in Actions.Keys) { + string[] Parts = Action.Split(' '); + if (Parts[0].Equals(args[0])) { + Println(Actions[Action].Description); + return; + } + } + Println("That command doesn't exist."); + }); + + AddCommand("print (text)", "Prints the given text.", (args) => { + Println(args[0]); + }); + + Term.SetDebugConsole(this); + } + public void CallCommand() { if (InputField.text.Length == 0) { return; @@ -60,40 +94,6 @@ public class DebugConsole : MonoBehaviour { TextField.text += text; } - private void Start() { - AddCommand("help", "Lists all commands.", (args) => { - Println("Commands:"); - foreach (string Action in Actions.Keys) { - Println("- " + Action); - } - }); - - AddCommand("help (command)", "Describes the given command.", (args) => { - // Check complete versions of the names (so you can do eg. help "help (command)") - foreach (string Action in Actions.Keys) { - if (Action.Equals(args[0])) { - Println(Actions[Action].Description); - return; - } - } - // Check just names - foreach (string Action in Actions.Keys) { - string[] Parts = Action.Split(' '); - if (Parts[0].Equals(args[0])) { - Println(Actions[Action].Description); - return; - } - } - Println("That command doesn't exist."); - }); - - AddCommand("print (text)", "Prints the given text.", (args) => { - Println(args[0]); - }); - - Term.SetDebugConsole(this); - } - private void Update() { if (Input.GetButtonDown("Console Toggle")) { Visible = !Visible;