Class TypeUtils
Editor utilities and helper functions for System.Type.
Inheritance
Namespace: FlaxEngine.Utilities
Assembly: FlaxEngine.CSharp.dll
Syntax
public static class TypeUtils : Object
Fields
CustomTypes
Custom list of scripting types containers. Can be used by custom scripting languages to provide types info for the editor.
Declaration
public static List<IScriptTypesContainer> CustomTypes
Field Value
|
System.Collections.Generic.List<IScriptTypesContainer>
|
Methods
CreateArrayInstance(ScriptType, Int32)
Creates a one-dimensional System.Array of the specified type and length.
Declaration
public static Array CreateArrayInstance(ScriptType elementType, int size)
Parameters
|
FlaxEditor.Scripting.ScriptType
elementType
The type of the array to create. |
|
System.Int32
size
The length of the array to create. |
Returns
|
System.Array
The created object or null if failed. |
CreateInstance(String)
Tries to create object instance of the given full typename. Searches in-build Flax Engine/Editor assemblies and game assemblies.
Declaration
public static object CreateInstance(string typeName)
Parameters
|
System.String
typeName
The full name of the type. |
Returns
|
System.Object
The created object or null if failed. |
GetDefaultValue(ScriptType)
Gets the default value for the given type (can be value type or reference type).
Declaration
public static object GetDefaultValue(ScriptType type)
Parameters
|
FlaxEditor.Scripting.ScriptType
type
The type. |
Returns
|
System.Object
The created instance. |
GetDerivedTypes(ScriptType, List<ScriptType>)
Gets all the derived types from the given base type (excluding that type) within all the loaded assemblies.
Declaration
public static void GetDerivedTypes(ScriptType baseType, List<ScriptType> result)
Parameters
|
FlaxEditor.Scripting.ScriptType
baseType
The base type. |
|
System.Collections.Generic.List<FlaxEditor.Scripting.ScriptType>
result
The result collection. Elements will be added to it. Clear it before usage. |
GetDerivedTypes(ScriptType, List<ScriptType>, Func<ScriptType, Boolean>)
Gets all the derived types from the given base type (excluding that type) within all the loaded assemblies.
Declaration
public static void GetDerivedTypes(ScriptType baseType, List<ScriptType> result, Func<ScriptType, bool> checkFunc)
Parameters
|
FlaxEditor.Scripting.ScriptType
baseType
The base type. |
|
System.Collections.Generic.List<FlaxEditor.Scripting.ScriptType>
result
The result collection. Elements will be added to it. Clear it before usage. |
|
System.Func<FlaxEditor.Scripting.ScriptType, System.Boolean>
checkFunc
Additional callback used to check if the given type is valid. Returns true if add type, otherwise false. |
GetDerivedTypes(ScriptType, List<ScriptType>, Func<ScriptType, Boolean>, Func<Assembly, Boolean>)
Gets all the derived types from the given base type (excluding that type) within all the loaded assemblies.
Declaration
public static void GetDerivedTypes(ScriptType baseType, List<ScriptType> result, Func<ScriptType, bool> checkFunc, Func<Assembly, bool> checkAssembly)
Parameters
|
FlaxEditor.Scripting.ScriptType
baseType
The base type. |
|
System.Collections.Generic.List<FlaxEditor.Scripting.ScriptType>
result
The result collection. Elements will be added to it. Clear it before usage. |
|
System.Func<FlaxEditor.Scripting.ScriptType, System.Boolean>
checkFunc
Additional callback used to check if the given type is valid. Returns true if add type, otherwise false. |
|
System.Func<System.Reflection.Assembly, System.Boolean>
checkAssembly
Additional callback used to check if the given assembly is valid. Returns true if search for types in the given assembly, otherwise false. |
GetDerivedTypes(Assembly, ScriptType, List<ScriptType>)
Gets all the derived types from the given base type (excluding that type) within the given assembly.
Declaration
public static void GetDerivedTypes(Assembly assembly, ScriptType baseType, List<ScriptType> result)
Parameters
|
System.Reflection.Assembly
assembly
The target assembly to check its types. |
|
FlaxEditor.Scripting.ScriptType
baseType
The base type. |
|
System.Collections.Generic.List<FlaxEditor.Scripting.ScriptType>
result
The result collection. Elements will be added to it. Clear it before usage. |
GetDerivedTypes(Assembly, ScriptType, List<ScriptType>, Func<ScriptType, Boolean>)
Gets all the derived types from the given base type (excluding that type) within the given assembly.
Declaration
public static void GetDerivedTypes(Assembly assembly, ScriptType baseType, List<ScriptType> result, Func<ScriptType, bool> checkFunc)
Parameters
|
System.Reflection.Assembly
assembly
The target assembly to check its types. |
|
FlaxEditor.Scripting.ScriptType
baseType
The base type. |
|
System.Collections.Generic.List<FlaxEditor.Scripting.ScriptType>
result
The result collection. Elements will be added to it. Clear it before usage. |
|
System.Func<FlaxEditor.Scripting.ScriptType, System.Boolean>
checkFunc
Additional callback used to check if the given type is valid. Returns true if add type, otherwise false. |
GetManagedType(String)
Tries to get the object type from the given full typename. Searches in-build Flax Engine/Editor assemblies and game assemblies.
Declaration
public static Type GetManagedType(string typeName)
Parameters
|
System.String
typeName
The full name of the type. |
Returns
|
System.Type
The type or null if failed. |
GetObjectType(Object)
Gets the script type of the object.
Declaration
public static ScriptType GetObjectType(object o)
Parameters
|
System.Object
o
The object. |
Returns
|
FlaxEditor.Scripting.ScriptType
The scripting type of that object. |
GetType(ScriptType)
Gets the managed type fo the script type (the first found from this or base types).
Declaration
public static Type GetType(ScriptType type)
Parameters
|
FlaxEditor.Scripting.ScriptType
type
The input type of the object to check. |
Returns
|
System.Type
The managed type. |
GetType(String)
Tries to get the object type from the given full typename. Searches in-build Flax Engine/Editor assemblies and game assemblies.
Declaration
public static ScriptType GetType(string typeName)
Parameters
|
System.String
typeName
The full name of the type. |
Returns
|
FlaxEditor.Scripting.ScriptType
The type or null if failed. |
GetTypeDisplayName(Type)
Gets the typename name for UI.
Declaration
public static string GetTypeDisplayName(this Type type)
Parameters
|
System.Type
type
The type. |
Returns
|
System.String
The display of the type. |
GetTypeName(Type)
Gets the typename full name.
Declaration
public static string GetTypeName(this Type type)
Parameters
|
System.Type
type
The type. |
Returns
|
System.String
The full typename of the type. |
GetTypes(List<ScriptType>, Func<ScriptType, Boolean>, Func<Assembly, Boolean>)
Gets all the types from all the loaded assemblies.
Declaration
public static void GetTypes(List<ScriptType> result, Func<ScriptType, bool> checkFunc, Func<Assembly, bool> checkAssembly)
Parameters
|
System.Collections.Generic.List<FlaxEditor.Scripting.ScriptType>
result
The result collection. Elements will be added to it. Clear it before usage. |
|
System.Func<FlaxEditor.Scripting.ScriptType, System.Boolean>
checkFunc
Additional callback used to check if the given type is valid. Returns true if add type, otherwise false. |
|
System.Func<System.Reflection.Assembly, System.Boolean>
checkAssembly
Additional callback used to check if the given assembly is valid. Returns true if search for types in the given assembly, otherwise false. |
GetTypes(Assembly, List<ScriptType>, Func<ScriptType, Boolean>)
Gets all the types within the given assembly.
Declaration
public static void GetTypes(Assembly assembly, List<ScriptType> result, Func<ScriptType, bool> checkFunc)
Parameters
|
System.Reflection.Assembly
assembly
The target assembly to check its types. |
|
System.Collections.Generic.List<FlaxEditor.Scripting.ScriptType>
result
The result collection. Elements will be added to it. Clear it before usage. |
|
System.Func<FlaxEditor.Scripting.ScriptType, System.Boolean>
checkFunc
Additional callback used to check if the given type is valid. Returns true if add type, otherwise false. |
GetTypesWithAttributeDefined(Assembly, Type, List<ScriptType>, Func<ScriptType, Boolean>)
Gets all the types that have the given attribute defined within the given assembly.
Declaration
public static void GetTypesWithAttributeDefined(Assembly assembly, Type attributeType, List<ScriptType> result, Func<ScriptType, bool> checkFunc)
Parameters
|
System.Reflection.Assembly
assembly
The target assembly to check its types. |
|
System.Type
attributeType
The attribute type. |
|
System.Collections.Generic.List<FlaxEditor.Scripting.ScriptType>
result
The result collection. Elements will be added to it. Clear it before usage. |
|
System.Func<FlaxEditor.Scripting.ScriptType, System.Boolean>
checkFunc
Additional callback used to check if the given type is valid. Returns true if add type, otherwise false. |
GetTypesWithAttributeDefined(Type, List<ScriptType>, Func<ScriptType, Boolean>, Func<Assembly, Boolean>)
Gets all the types that have the given attribute defined within all the loaded assemblies.
Declaration
public static void GetTypesWithAttributeDefined(Type attributeType, List<ScriptType> result, Func<ScriptType, bool> checkFunc, Func<Assembly, bool> checkAssembly)
Parameters
|
System.Type
attributeType
The attribute type. |
|
System.Collections.Generic.List<FlaxEditor.Scripting.ScriptType>
result
The result collection. Elements will be added to it. Clear it before usage. |
|
System.Func<FlaxEditor.Scripting.ScriptType, System.Boolean>
checkFunc
Additional callback used to check if the given type is valid. Returns true if add type, otherwise false. |
|
System.Func<System.Reflection.Assembly, System.Boolean>
checkAssembly
Additional callback used to check if the given assembly is valid. Returns true if search for types in the given assembly, otherwise false. |
IsDelegate(Type)
Checks if the input type represents a delegate.
Declaration
public static bool IsDelegate(this Type type)
Parameters
|
System.Type
type
The input type of the object to check. |
Returns
|
System.Boolean
Returns true if the input type represents a delegate. |
IsStructure(Type)
Checks if the input type represents a structure (value type but not enum nor primitive type).
Declaration
public static bool IsStructure(this Type type)
Parameters
|
System.Type
type
The input type of the object to check. |
Returns
|
System.Boolean
Returns true if the input type represents a structure (value type but not enum nor primitive type). |