Supported Parameter Types/Type
The System.Type
type is supported into the console, so it is possible to write functions that take a type argument.
An example of this in operation is the Component.FindInScenes command, which allows you to search the scene for all components of a specific type (similar to Unity's GameObject.FindObjectsOfType(System.Type type)
function.
Filtering by SubType
As it is unlikely your command will want to handle every type that exists in the system, you can filter the valid input (and the suggestions it produces, by using a [SubtypeOf()]
attribute on the Type parameter in code. For example, the Component.FindInScenes command looks like the following, in code:
[ConsoleCommand] private static string FindInScenes([SubtypeOf(typeof(Component))] Type type, bool includeInactive=false)
This will then only show types derived from UnityEngine.Component
in the suggestions, and will reject entry of types that do not match.