Skip to content

Commit 12c8460

Browse files
committed
Added overload to DevConsoleCommand attribute to set whether the command is only available in dev builds.
1 parent 168e980 commit 12c8460

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Runtime/DevConsoleCommandAttribute.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,21 @@ public sealed class DevConsoleCommandAttribute : Attribute
2121
/// <param name="name">Name used to call the command (e.g. "print").</param>
2222
/// <param name="aliases">Optional names that can be used to call the command, seperated by commas (e.g. "display,say").</param>
2323
/// <param name="helpText">Description of the command (e.g. "Display a message in the developer console").</param>
24+
/// <param name="onlyInDevBuild">Whether to only add the command if the project is a development build.</param>
2425
/// <param name="parameterHelpText">Descriptions of the parameters (e.g. "Message to display in the developer console").</param>
25-
public DevConsoleCommandAttribute(string name, string aliases, string helpText, params string[] parameterHelpText)
26+
public DevConsoleCommandAttribute(string name, string aliases, string helpText, bool onlyInDevBuild, params string[] parameterHelpText)
2627
{
2728
Name = name;
2829
Aliases = aliases.Split(',');
2930
HelpText = helpText;
3031
ParameterHelpText = parameterHelpText ?? new string[0];
32+
OnlyInDevBuild = onlyInDevBuild;
33+
}
34+
35+
/// <inheritdoc cref="DevConsoleCommandAttribute(string, string, string, bool, string[])" />
36+
public DevConsoleCommandAttribute(string name, string aliases, string helpText, params string[] parameterHelpText)
37+
: this(name, aliases, helpText, false, parameterHelpText)
38+
{
3139
}
3240

3341
#endregion
@@ -54,6 +62,8 @@ public DevConsoleCommandAttribute(string name, string aliases, string helpText,
5462
/// </summary>
5563
internal string[] ParameterHelpText { get; }
5664

65+
internal bool OnlyInDevBuild { get; }
66+
5767
#endregion
5868
}
5969
}

Runtime/DevConsoleMono.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,7 @@ private void InitAttributeCommands()
17641764
DevConsoleCommandAttribute commandAttribute = (DevConsoleCommandAttribute)attribute;
17651765
if (commandAttribute != null)
17661766
{
1767-
AddCommand(Command.Create(commandAttribute, method));
1767+
AddCommand(Command.Create(commandAttribute, method), commandAttribute.OnlyInDevBuild);
17681768
}
17691769
}
17701770
}

0 commit comments

Comments
 (0)