void Awake() { if (Instance != null) { CleanLog.LogError("Cannot have multiple instances of Drop Console."); this.enabled = false; return; } if (ConsoleFont == null) { SetConsoleFont(Resources.Load <Font>("Fonts/DroidSansMono") ?? Resources.GetBuiltinResource <Font>("Arial.ttf")); } CleanLog.LogFilter = CleanLog.LogType.All; CleanLog.LogFileFilter = CleanLog.LogType.All; CleanLog.Setup(500, true); Instance = this; DontDestroyOnLoad(this.gameObject); RegisterCommand("help", ListAllCommands, "Lists all registered console commands"); RegisterCommand("clear", ClearLists, "[log|cmds|all] Clears console log, command history, or both"); RegisterCommand("echo", EchoString, "Echoes a string to the console"); RegisterCommand("loadScene", LoadScene, "Loads a scene added to the project via Build Settings"); RegisterCommand("screenshot", TakeScreenshot, "filename [supersize] Saves a screenshot. Supersize is a factor to increase the resolution"); RegisterCommand("version", PrintVersion, "Prints the current application version"); }
string LogError(params string[] args) { #if USE_CLEAN_LOGGER CleanLog.LogError(string.Join(" ", args)); #else Debug.LogError(string.Join(" ", args)); #endif return("OK"); }
void Start() { if (consolePanel == null || consoleInput == null) { CleanLog.LogError("UI Components are not set up!"); this.enabled = false; return; } panelHeight = consolePanel.rect.height; consolePanel.anchoredPosition = Vector2.zero; consoleInput.onValidateInput += ValidateConsoleInput; consoleInput.onEndEdit.AddListener(EndEditConsoleInput); if (ConsoleFont != null) { consoleInput.textComponent.font = ConsoleFont; consoleInput.placeholder.GetComponent <Text>().font = ConsoleFont; consoleInput.textComponent.fontSize = consoleFontSize; consoleInput.placeholder.GetComponent <Text>().fontSize = consoleFontSize; } if (errorSprite != null && warningSprite != null) { errorIndicator.sprite = errorSprite; errorIndicator.color = errorColor; warningIndicator.sprite = warningSprite; warningIndicator.color = warningColor; warningIndicator.gameObject.SetActive(false); errorIndicator.gameObject.SetActive(false); } if (fpsText != null) { RegisterCommand("fps", ToggleFPS, "[show|hide] Shows or hides FPS counter"); } Input.multiTouchEnabled = true; RegisterLogging(); ParseCommand("version"); }