| | | 1 | | // Copyright (c) 2020-2024 dotBunny Inc. |
| | | 2 | | // dotBunny licenses this file to you under the BSL-1.0 license. |
| | | 3 | | // See the LICENSE file in the project root for more information. |
| | | 4 | | |
| | | 5 | | using System.Collections.Generic; |
| | | 6 | | |
| | | 7 | | namespace GDX.Developer.ConsoleCommands |
| | | 8 | | { |
| | | 9 | | #if UNITY_2022_2_OR_NEWER |
| | | 10 | | public class ConsoleVariablesConsoleCommand : ConsoleCommandBase |
| | | 11 | | { |
| | | 12 | | /// <inheritdoc /> |
| | | 13 | | public override bool Evaluate(float deltaTime) |
| | 0 | 14 | | { |
| | 0 | 15 | | TextGenerator textGenerator = new TextGenerator(); |
| | 0 | 16 | | List<string> sortedVariables = new List<string>(Console.GetVariableNamesCopy()); |
| | 0 | 17 | | sortedVariables.Sort(); |
| | 0 | 18 | | int variableCount = sortedVariables.Count; |
| | 0 | 19 | | Console.ConsoleAccessLevel maxAccessLevel = Console.GetAccessLevel(); |
| | 0 | 20 | | for (int i = 0; i < variableCount; i++) |
| | 0 | 21 | | { |
| | 0 | 22 | | ConsoleVariableBase variable = Console.GetVariable(sortedVariables[i]); |
| | 0 | 23 | | if (variable.GetAccessLevel() > maxAccessLevel) |
| | 0 | 24 | | { |
| | 0 | 25 | | continue; |
| | | 26 | | } |
| | | 27 | | |
| | 0 | 28 | | textGenerator.AppendLine(variable.GetName()); |
| | 0 | 29 | | textGenerator.AppendLine($"\t{variable.GetDescription()}"); |
| | 0 | 30 | | textGenerator.AppendLine($"\tCurrent: {variable.GetCurrentValueAsString()}"); |
| | 0 | 31 | | textGenerator.AppendLine($"\tDefault: {variable.GetDefaultValueAsString()}"); |
| | 0 | 32 | | } |
| | | 33 | | |
| | 0 | 34 | | UnityEngine.Debug.Log(textGenerator.ToString()); |
| | 0 | 35 | | return true; |
| | 0 | 36 | | } |
| | | 37 | | |
| | | 38 | | /// <inheritdoc /> |
| | | 39 | | public override string GetKeyword() |
| | 7 | 40 | | { |
| | 7 | 41 | | return "cvars"; |
| | 7 | 42 | | } |
| | | 43 | | |
| | | 44 | | /// <inheritdoc /> |
| | | 45 | | public override string GetHelpMessage() |
| | 0 | 46 | | { |
| | 0 | 47 | | return "Return a list of all registered console variables."; |
| | 0 | 48 | | } |
| | | 49 | | } |
| | | 50 | | #endif // UNITY_2022_2_OR_NEWER |
| | | 51 | | } |