public static ConsoleModel getGameConsoleModel() { if (consoleModel == null) { consoleModel = new ConsoleModel(); consoleModel.init(); consoleModel.enable(); } return(consoleModel); }
void Start() { consoleModel = Shell.getGameConsoleModel(); consoleModel.enable(); //model.onClear += consoleModel.onHideConsole += hideConsole; consoleModel.onHideEditor += hideEditor; consoleModel.onHideHistory += hideHistory; consoleModel.onHideLog += hideLog; consoleModel.onLoadScript += (v => codeEditor = v); consoleModel.onNewMessage += (m => newPrint = true); consoleModel.onRunCurrent += (() => consoleModel.runString(codeEditor)); consoleModel.onSaveCurrent += (() => consoleModel.saveScriptWithCode(uri, codeEditor)); consoleModel.onSaveToNew += (v => consoleModel.saveScriptWithCode(v, codeEditor)); consoleModel.onShowAll += showConsole; consoleModel.onShowEditor += showEditor; consoleModel.onShowHistory += showHistory; consoleModel.onShowLog += showLog; // Assure uniqueness if (instance != null) { consoleModel.printError("There is already a console in game"); Debug.Log("There is already a console in game"); Destroy(this); return; } instance = this; historyRank = -1; commandSave = ""; historyScroll = Vector2.zero; currentConsoleCode = new List <string> (); parDepth = 0; currentConsoleCommand = ""; codeEditor = ""; uri = null; mainBox = new Rect(); historyBox = new Rect(); consoleBox = new Rect(); editorBox = new Rect(); logBox = new Rect(); updatePositions(); cacheScreenHeight = Screen.height; cacheScreenWidth = Screen.width; logScroll = Vector2.zero; }
public static void init() { if (!isInit) { isInit = true; if (loggerModel == null) { loggerModel = new LoggerModel(); } if (consoleModel == null) { consoleModel = new ConsoleModel(); consoleModel.init(); consoleModel.enable(); } } }
void OnEnable() { if (consoleModel == null) { consoleModel = Shell.getEditorConsoleModel(); loggerModel = Shell.getLoggerModel(); historyRank = -1; commandSave = null; currentConsoleCode = new List <string> (); search = ""; } consoleModel.enable(); //model.onClear += ; consoleModel.onHideConsole += (() => showEditor = showHistory = false); consoleModel.onHideEditor += (() => showEditor = false); consoleModel.onHideHistory += (() => showHistory = false); consoleModel.onHideLog += (() => showLog = false); consoleModel.onLoadScript += (v => editorCode = v); consoleModel.onNewMessage += (s => newPrint = true); consoleModel.onRunCurrent += (() => consoleModel.runString(editorCode)); consoleModel.onSaveCurrent += (() => consoleModel.saveScriptWithCode(uri, editorCode)); consoleModel.onSaveToNew += (newURI => consoleModel.saveScriptWithCode(newURI, editorCode)); consoleModel.onShowAll += (() => showEditor = showHistory = true); consoleModel.onShowEditor += (() => showEditor = true); consoleModel.onShowHistory += (() => showHistory = true); consoleModel.onShowLog += (() => showLog = true); loggerModel.onLog += (log => newLog = true); loggerModel.onShow += (() => showLog = true); loggerModel.onHide += (() => showLog = false); // loggerModel.onClear += ; // loggerModel.onTypeChange += ; // loggerModel.onChannelChange += ; EditorApplication.playmodeStateChanged += onPlayModeChanged; }