Difference between revisions of "Command Limitations"
(→Static / Instance members) |
(→Parameters marked out and ref) |
||
Line 15: | Line 15: | ||
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 <code>TypeHandlers</code> for your custom Types (see [[Type Handlers]]). | 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 <code>TypeHandlers</code> for your custom Types (see [[Type Handlers]]). | ||
− | ===Parameters | + | ===Parameters Marked <code>out</code> and <code>ref</code>=== |
The console does not support <code>out</code> or <code>ref</code> parameters yet. | The console does not support <code>out</code> or <code>ref</code> parameters yet. | ||
Revision as of 17:09, 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 Type Handlers)
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 Type Handlers).
Exceptions
Commands backed by methods or properties may throw exceptions. These will be caught by the console and the exception error message will be displayed in the console output, in lieu of a return value.