private void OnEnable() { // Intercept debug entries Application.logMessageReceivedThreaded -= ReceivedLog; Application.logMessageReceivedThreaded += ReceivedLog; // Listen for entered commands commandInputField.onValidateInput -= OnValidateCommand; commandInputField.onValidateInput += OnValidateCommand; if (receiveLogcatLogsInAndroid) { #if !UNITY_EDITOR && UNITY_ANDROID if (logcatListener == null) { logcatListener = new DebugLogLogcatListener(); } logcatListener.Start(logcatArguments); #endif } DebugLogConsole.AddCommand("save_logs", "Saves logs to a file", SaveLogsToFile); //Debug.LogAssertion( "assert" ); //Debug.LogError( "error" ); //Debug.LogException( new System.IO.EndOfStreamException() ); //Debug.LogWarning( "warning" ); //Debug.Log( "log" ); }
/// <summary> /// Command field input is changed, check if command is submitted /// </summary> /// <param name="text">Text sent to command field</param> /// <param name="charIndex">Index of current entry in command field</param> /// <param name="addedChar">Character of current entry in command field</param> /// <returns></returns> public char OnValidateCommand(string text, int charIndex, char addedChar) { // If command is submitted if (addedChar == '\n') { // Clear the command field if (clearCommandAfterExecution) { commandInputField.text = ""; } if (text.Length > 0) { // Execute the command DebugLogConsole.ExecuteCommand(text); // Snap to bottom and select the latest entry SetSnapToBottom(true); } return('\0'); } return(addedChar); }
// Command field input is changed, check if command is submitted public char OnValidateCommand(string text, int charIndex, char addedChar) { // If command is submitted if (addedChar == '\n') { // Clear the command field if (clearCommandAfterExecution) { commandInputField.text = ""; } if (text.Length > 0) { // Execute the command DebugLogConsole.ExecuteCommand(text); // Snap to bottom and select the latest entry OnSnapToBottomChanged(true); if (indicesOfListEntriesToShow.Count > 0) { OnLogClicked(indicesOfListEntriesToShow.Count - 1); } } return('\0'); } return(addedChar); }
// Command field input is changed, check if command is submitted public char OnValidateCommand(string text, int charIndex, char addedChar) { if (addedChar == '\t') // Autocomplete attempt { text = text.TrimStart(); if (!string.IsNullOrEmpty(text)) { DebugLogConsole.AutoCompleteResults results = DebugLogConsole.GetAutoComplete(text); if (results.error == null) { if (results.replacement != null) { commandInputField.text = results.replacement; } if (results.options.Count > 1) { Debug.Log("Options: " + String.Join(", ", results.options)); } } else { Debug.LogWarning(results.error); } } return('\0'); } else if (addedChar == '\n') // Command is submitted { // Clear the command field if (clearCommandAfterExecution) { commandInputField.text = ""; } if (text.Length > 0) { if (commandHistory.Count == 0 || commandHistory[commandHistory.Count - 1] != text) { commandHistory.Add(text); } commandHistoryIndex = -1; // Execute the command DebugLogConsole.ExecuteCommand(text); // Snap to bottom and select the latest entry SetSnapToBottom(true); } return('\0'); } return(addedChar); }
private void OnDisable() { if( instance != this ) return; // Stop receiving debug entries Application.logMessageReceived -= ReceivedLog; #if !UNITY_EDITOR && UNITY_ANDROID if( logcatListener != null ) logcatListener.Stop(); #endif // Stop receiving commands commandInputField.onValidateInput -= OnValidateCommand; DebugLogConsole.RemoveCommand( "save_logs" ); }
// Command field input is changed, check if command is submitted public char OnValidateCommand(string text, int charIndex, char addedChar) { if (addedChar == '\t') // Autocomplete attempt { if (!string.IsNullOrEmpty(text)) { string autoCompletedCommand = DebugLogConsole.GetAutoCompleteCommand(text); if (!string.IsNullOrEmpty(autoCompletedCommand)) { commandInputField.text = autoCompletedCommand; } } return('\0'); } else if (addedChar == '\n') // Command is submitted { // Clear the command field if (clearCommandAfterExecution) { commandInputField.text = ""; } if (text.Length > 0) { if (commandHistory.Count == 0 || commandHistory[commandHistory.Count - 1] != text) { commandHistory.Add(text); } commandHistoryIndex = -1; // Execute the command DebugLogConsole.ExecuteCommand(text); // Snap to bottom and select the latest entry SetSnapToBottom(true); } return('\0'); } return(addedChar); }
public void Init(ConsoleMethodInfo consoleMethodInfo) { Input.placeholder.GetComponent <Text>().text = "请输入参数,类型在上面,每个参数用空格分隔"; Input.gameObject.SetActive(consoleMethodInfo.parameterTypes.Length > 0); oldName = $">{consoleMethodInfo.command}({string.Join("",consoleMethodInfo.parameters)})"; NameTxt.text = oldName; DescTxt.text = consoleMethodInfo.description; Btn.onClick.AddListener(() => { DebugLogConsole.ExecuteCommand($"{consoleMethodInfo.command} {Input.text}"); btnImg.color = Color.green; NameTxt.text = "执行成功!!"; StartCoroutine(Delay(1, () => { btnImg.color = Color.white; NameTxt.text = oldName; })); }); }
// Click the submit btn public void SubmitInputCommand() { var text = commandInputField.text; // Clear the command field if (clearCommandAfterExecution) { commandInputField.text = ""; } if (text.Length > 0) { // Execute the command DebugLogConsole.ExecuteCommand(text); // Snap to bottom and select the latest entry SetSnapToBottom(true); } }
private void OnDisable() { if (Instance != this) { return; } // Stop receiving debug entries Application.logMessageReceivedThreaded -= ReceivedLog; #if !UNITY_EDITOR && UNITY_ANDROID if (logcatListener != null) { logcatListener.Stop(); } #endif DebugLogConsole.RemoveCommand("save_logs"); }
public void SendCommandButtonPressed() { if (clearCommandAfterExecution) { commandInputField.text = ""; } if (commandInputField.text.Length > 0) { // Execute the command DebugLogConsole.ExecuteCommand(commandInputField.text); // Snap to bottom and select the latest entry OnSnapToBottomChanged(true); if (indicesOfListEntriesToShow.Count > 0) { OnLogClicked(indicesOfListEntriesToShow.Count - 1); } } }
private void OnEnable() { // Only one instance of debug console is allowed if (instance == null) { instance = this; pooledLogItems = new List <DebugLogItem>(); commandHistory = new CircularBuffer <string>(commandHistorySize); canvasTR = (RectTransform)transform; // Associate sprites with log types logSpriteRepresentations = new Dictionary <LogType, Sprite> { { LogType.Log, infoLog }, { LogType.Warning, warningLog }, { LogType.Error, errorLog }, { LogType.Exception, errorLog }, { LogType.Assert, errorLog } }; // Initially, all log types are visible filterInfoButton.color = filterButtonsSelectedColor; filterWarningButton.color = filterButtonsSelectedColor; filterErrorButton.color = filterButtonsSelectedColor; collapsedLogEntries = new List <DebugLogEntry>(128); collapsedLogEntriesMap = new Dictionary <DebugLogEntry, int>(128); uncollapsedLogEntriesIndices = new DebugLogIndexList(); indicesOfListEntriesToShow = new DebugLogIndexList(); recycledListView.Initialize(this, collapsedLogEntries, indicesOfListEntriesToShow, logItemPrefab.Transform.sizeDelta.y); recycledListView.UpdateItemsInTheList(true); nullPointerEventData = new PointerEventData(null); // If it is a singleton object, don't destroy it between scene changes if (singleton) { DontDestroyOnLoad(gameObject); } } else if (this != instance) { Destroy(gameObject); return; } // Intercept debug entries Application.logMessageReceived -= ReceivedLog; Application.logMessageReceived += ReceivedLog; if (receiveLogcatLogsInAndroid) { #if !UNITY_EDITOR && UNITY_ANDROID if (logcatListener == null) { logcatListener = new DebugLogLogcatListener(); } logcatListener.Start(logcatArguments); #endif } // Listen for entered commands commandInputField.onValidateInput -= OnValidateCommand; commandInputField.onValidateInput += OnValidateCommand; if (minimumHeight < 200f) { minimumHeight = 200f; } DebugLogConsole.AddCommandInstance("save_logs", "Saves logs to a file", "SaveLogsToFile", this); //Debug.LogAssertion( "assert" ); //Debug.LogError( "error" ); //Debug.LogException( new System.IO.EndOfStreamException() ); //Debug.LogWarning( "warning" ); //Debug.Log( "log" ); }