-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ Added inspector configurable commands + Added some documentation + Added "hello world" command example + Added "NonLoadableCommand" attribute * Updated Readme * Fixed namespace/console name convention
- Loading branch information
1 parent
83cd6a2
commit b8bc660
Showing
18 changed files
with
325 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
using DevConsole.Behaviours; | ||
|
||
namespace DevConsole.Commands | ||
{ | ||
/// <summary> | ||
/// Put onto <see cref="DevConsoleCommand"/> implementations that shouldn't be loaded initially by the | ||
/// <see cref="DevConsoleBehaviour"/>. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Class)] | ||
public class NonLoadableCommandAttribute : Attribute { } | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.Events; | ||
|
||
namespace DevConsole.Commands | ||
{ | ||
[Serializable, NonLoadableCommand] | ||
public class UnityEventCommand : DevConsoleCommand | ||
{ | ||
[SerializeField, | ||
Tooltip("Names that can be used to invoke this command. All entries are set to lowercase and trimmed before comparison.")] | ||
private string[] _names; | ||
|
||
[SerializeField, | ||
Tooltip("The text that appears when a user types \"help [your-command-name]\"")] | ||
private string _helpText; | ||
|
||
[SerializeField, | ||
Tooltip("Enable if this command should only be used during \"Dev Mode\".")] | ||
private bool _devModeOnly; | ||
|
||
[SerializeField, | ||
Tooltip("Enable if this command should only be used during \"Cheat Mode\".")] | ||
private bool _cheatModeOnly; | ||
|
||
[SerializeField, | ||
Tooltip("Invoked when this command is executed. It'll be invoked before \"onParameterInvoke\".")] | ||
private UnityEvent _onInvoke; | ||
|
||
[SerializeField, | ||
Tooltip("Invoked when this command is executed. It's invoked with all parameters sent to the command and invoked after \"onInvoke\".")] | ||
private StringParamUnityEvent _onParameterInvoke; | ||
|
||
public override string[] GetNames() => _names; | ||
|
||
public override string GetHelp() => _helpText; | ||
|
||
public override bool devModeOnly => _devModeOnly; | ||
|
||
public override bool cheatModeOnly => _cheatModeOnly; | ||
|
||
public override void Execute(List<string> parameters) | ||
{ | ||
_onInvoke?.Invoke(); | ||
_onParameterInvoke?.Invoke(parameters); | ||
} | ||
} | ||
|
||
[Serializable] | ||
public class StringParamUnityEvent : UnityEvent<List<string>> { } | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
using System.Collections.Generic; | ||
using DevConsole.Behaviours; | ||
using DevConsole.Commands; | ||
using DevConsole.Enums; | ||
using static DevConsole.Behaviours.DevConsoleBehaviour; | ||
|
||
namespace DevConsole | ||
{ | ||
/// <summary> | ||
/// Allows quick and easy access to <see cref="DevConsoleBehaviour"/> instance functionality. | ||
/// </summary> | ||
public static class Console | ||
{ | ||
/// <summary> | ||
/// Prints a message to the dev console, using the <see cref="DevConsoleBehaviour"/> <see cref="DevConsoleBehaviour.Instance"/>. | ||
/// </summary> | ||
/// <param name="message">The message to print.</param> | ||
public static void Print(string message) => Instance?.Print(message); | ||
|
||
/// <summary> | ||
/// Prints a message to the dev console, using the <see cref="DevConsoleBehaviour"/> | ||
/// <see cref="DevConsoleBehaviour.Instance"/> of the specified <see cref="DevConsolePrintType"/>. | ||
/// </summary> | ||
/// <param name="message">The message to print.</param> | ||
/// <param name="printType">he message type.</param> | ||
public static void Print(string message, DevConsolePrintType printType) => Instance?.Print(message, printType); | ||
|
||
/// <summary> | ||
/// Prints an error message to the dev console, using the <see cref="DevConsoleBehaviour"/> <see cref="DevConsoleBehaviour.Instance"/>. | ||
/// </summary> | ||
/// <param name="message">The error message to print.</param> | ||
public static void PrintError(string message) => Instance?.Print(message, DevConsolePrintType.Error); | ||
|
||
/// <summary> | ||
/// Prints a warning message to the dev console, using the <see cref="DevConsoleBehaviour"/> <see cref="DevConsoleBehaviour.Instance"/>. | ||
/// </summary> | ||
/// <param name="message">The warning message to print.</param> | ||
public static void PrintWarning(string message) => Instance?.Print(message, DevConsolePrintType.Warning); | ||
|
||
/// <summary> | ||
/// Prints a success message to the dev console, using the <see cref="DevConsoleBehaviour"/> <see cref="DevConsoleBehaviour.Instance"/>. | ||
/// </summary> | ||
/// <param name="message">The success message to print.</param> | ||
public static void PrintSuccess(string message) => Instance?.Print(message, DevConsolePrintType.Success); | ||
|
||
/// <summary> | ||
/// Toggles the <see cref="DevConsoleBehaviour"/> <see cref="DevConsoleBehaviour.Instance"/>. | ||
/// </summary> | ||
public static void Toggle() => Instance?.Toggle(); | ||
|
||
/// <summary> | ||
/// Opens the <see cref="DevConsoleBehaviour"/> <see cref="DevConsoleBehaviour.Instance"/>. | ||
/// </summary> | ||
public static void Open() => Instance?.Open(); | ||
|
||
/// <summary> | ||
/// Closes the <see cref="DevConsoleBehaviour"/> <see cref="DevConsoleBehaviour.Instance"/>. | ||
/// </summary> | ||
public static void Close() => Instance?.Close(); | ||
|
||
/// <summary> | ||
/// Clears the <see cref="DevConsoleBehaviour"/> <see cref="DevConsoleBehaviour.Instance"/>. | ||
/// </summary> | ||
public static void Clear() => Instance?.Clear(); | ||
|
||
/// <summary> | ||
/// Gets all registered commands from the <see cref="DevConsoleBehaviour"/> <see cref="DevConsoleBehaviour.Instance"/>. | ||
/// </summary> | ||
/// <returns><see cref="List{T}"/> of <see cref="DevConsoleCommand"/> registered in the <see cref="DevConsoleBehaviour"/> <see cref="DevConsoleBehaviour.Instance"/>.</returns> | ||
public static List<DevConsoleCommand> GetAllRegisteredCommands() => Instance?.GetAllRegisteredCommands(); | ||
|
||
/// <summary> | ||
/// Gets a command matching the given <see cref="name"/>. | ||
/// </summary> | ||
/// <param name="name">The name of the command to get.</param> | ||
/// <returns>A <see cref="DevConsoleCommand"/> if one exists for the given name.</returns> | ||
public static DevConsoleCommand GetCommandByName(string name) => Instance?.GetCommandByName(name); | ||
|
||
/// <summary> | ||
/// Checks whether or not the <see cref="DevConsoleBehaviour"/> <see cref="DevConsoleBehaviour.Instance"/> is open. | ||
/// </summary> | ||
public static bool isOpen => Instance?.isOpen ?? false; | ||
|
||
/// <summary> | ||
/// Checks whether or not the <see cref="DevConsoleBehaviour"/> <see cref="DevConsoleBehaviour.Instance"/> has dev mode enabled. | ||
/// </summary> | ||
public static bool isDevModeEnabled => Instance?.isDevModeEnabled ?? false; | ||
|
||
/// <summary> | ||
/// Checks whether or not the <see cref="DevConsoleBehaviour"/> <see cref="DevConsoleBehaviour.Instance"/> has the cheat mode enabled. | ||
/// </summary> | ||
public static bool isCheatModeEnabled => Instance?.isCheatModeEnabled ?? false; | ||
|
||
/// <summary> | ||
/// The current input buffer for the <see cref="DevConsoleBehaviour"/> <see cref="DevConsoleBehaviour.Instance"/>. | ||
/// </summary> | ||
public static string inputBuffer | ||
{ | ||
get => Instance?.inputBuffer; | ||
set | ||
{ | ||
if (Instance) | ||
{ | ||
Instance.inputBuffer = value; | ||
} | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.