| | 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 | | namespace GDX.Developer.ConsoleCommands |
| | 6 | | { |
| | 7 | | #if UNITY_2022_2_OR_NEWER |
| | 8 | | public class WatchListConsoleCommand : ConsoleCommandBase |
| | 9 | | { |
| 7 | 10 | | string m_Filter = null; |
| | 11 | |
|
| | 12 | | public override bool Evaluate(float deltaTime) |
| 0 | 13 | | { |
| 0 | 14 | | TextGenerator enabledGenerator = new TextGenerator(); |
| 0 | 15 | | enabledGenerator.AppendLine("Enabled Watches"); |
| | 16 | |
|
| 0 | 17 | | TextGenerator disabledGenerator = new TextGenerator(); |
| 0 | 18 | | disabledGenerator.AppendLine("Disabled Watches"); |
| | 19 | |
|
| 0 | 20 | | bool isFiltering = !string.IsNullOrEmpty(m_Filter); |
| | 21 | |
|
| 0 | 22 | | WatchProvider.WatchList watches = WatchProvider.GetWatchList(); |
| | 23 | |
|
| 0 | 24 | | for (int i = 0; i < watches.Count; i++) |
| 0 | 25 | | { |
| 0 | 26 | | if (isFiltering && !watches.Identfiers[i].Contains(m_Filter)) |
| 0 | 27 | | { |
| 0 | 28 | | continue; |
| | 29 | | } |
| | 30 | |
|
| 0 | 31 | | if (watches.IsActive[i]) |
| 0 | 32 | | { |
| 0 | 33 | | enabledGenerator.AppendLine($"\t{watches.Identfiers[i]} : {watches.DisplayNames[i]}"); |
| 0 | 34 | | } |
| | 35 | | else |
| 0 | 36 | | { |
| 0 | 37 | | disabledGenerator.AppendLine($"\t{watches.Identfiers[i]} : {watches.DisplayNames[i]}"); |
| 0 | 38 | | } |
| 0 | 39 | | } |
| 0 | 40 | | enabledGenerator.AppendLine(disabledGenerator.ToString()); |
| 0 | 41 | | UnityEngine.Debug.Log(enabledGenerator.ToString()); |
| 0 | 42 | | return true; |
| 0 | 43 | | } |
| | 44 | |
|
| | 45 | | /// <inheritdoc /> |
| | 46 | | public override string GetKeyword() |
| 7 | 47 | | { |
| 7 | 48 | | return "watch.list"; |
| 7 | 49 | | } |
| | 50 | |
|
| | 51 | | /// <inheritdoc /> |
| | 52 | | public override string GetHelpUsage() |
| 0 | 53 | | { |
| 0 | 54 | | return "watch.list <filter>"; |
| 0 | 55 | | } |
| | 56 | |
|
| | 57 | | /// <inheritdoc /> |
| | 58 | | public override string GetHelpMessage() |
| 0 | 59 | | { |
| 0 | 60 | | return "Return a list of all registered watches, with the ability to filter."; |
| 0 | 61 | | } |
| | 62 | |
|
| | 63 | | /// <inheritdoc /> |
| | 64 | | public override ConsoleCommandBase GetInstance(string context) |
| 0 | 65 | | { |
| 0 | 66 | | return new WatchListConsoleCommand { m_Filter = context }; |
| 0 | 67 | | } |
| | 68 | | } |
| | 69 | | #endif // UNITY_2022_2_OR_NEWER |
| | 70 | | } |