Difference between revisions of "Command Limitations"
(Created page with "Console commands can be made out of class-member methods, variables and properties, but there are some limitations on how they can be defined: ==Access Level== Reflex Console...") |
|||
Line 1: | Line 1: | ||
+ | [[Category:Commands]] | ||
Console commands can be made out of class-member methods, variables and properties, but there are some limitations on how they can be defined: | Console commands can be made out of class-member methods, variables and properties, but there are some limitations on how they can be defined: | ||
Revision as of 16:31, 30 August 2017
Console commands can be made out of class-member methods, variables and properties, but there are some limitations on how they can be defined:
Contents
Access Level
Reflex Console Commands can be public, protected, or private: any access level is valid. This means you can keep debug commands hidden from your other game code, but still expose them to the Reflex Console
Static / Instance members
A static member of any class or struct may be made into a command.
Currently, non-static members can only be made into commands if the defining class is a UnityEngine.Component or a class derived from it. Note: this includes any MonoBehaviour scripts you have created, so most of your game code will be able to use non-static members.
This is very useful if you wish to address in-game objects directly from the console. See Monobhaviour Types for details.
Valid Method Commands
For methods that are to be implemented, it is important that all parameters have a type that is supported by the console system (See Supported Types). Alternatively, you can provide custom TypeHandlers
for your custom Types (see Type Handlers).
Parameters marked out
and ref
The console does not support out
or ref
parameters yet.
Optional Parameters
Optional parameters are supported and will use the default values from the method declaration if no value is supplied by the user.
Return types
All return types are valid. Any returned objects will be converted to string (using ToString()) and printed to the console output.
Valid Field Commands
Fields must have a supported type, or be of a type with a custom TypeHandler (see Supported Types and TypeHandlers)
Valid Property Commands
Properties may implement get{}, set{} or both.
If the property implements set{} then it must have a supported type, or be of a type with a custom TypeHandler (see Supported Types and TypeHandlers).
Exceptions
Commands backed by methods or properties may throw exceptions. These will be caught by the console and displayed in the console output, in lieu of a return value.