class
MonoUtil
Utility class containing methods for various common Mono/Script related operations.
Public
Methods
staticMonoToWString
Converts a Mono (managed) string to a native wide string.
staticMonoToString
Converts a Mono (managed) string to a native narrow string.
staticWstringToMono
Converts a native wide string to a Mono (managed) string.
staticWstringToMono
Converts a native wide string to a Mono (managed) string.
staticStringToMono
Converts a native narrow string to a Mono (managed) string.
staticStringToMono
Converts a native narrow string to a Mono (managed) string.
staticGetClassName
Outputs name and namespace for the type of the specified object.
staticGetClassName
Outputs name and namespace for the specified type.
staticGetClassName
Outputs name and namespace for the specified type.
staticGetClass
Returns the class of the provided object.
staticGetClass
Returns the class of the provided type.
staticGetType
Returns the type of the provided object.
staticGetType
Returns the type of the provided class.
staticNewGcHandle
Creates a new GC handle for the provided managed object.
The handle can be stored and later used for retrieving the MonoObject* related to it by calling getObjectFromGCHandle(). This is a strong handle, meaning it will prevent the garbage collector from collecting the object until it is released by calling freeGCHandle().
- object
- Managed object to create the handle for.
- pinned
- If true the object will be pinned in memory, meaning you will be allowed to store a reference to the MonoObject directly. Never store MonoObject* unless they have been previously pinned (instead use getObjectFromGCHandle*( to get the current pointer). Note that pinning can have an impact on memory fragmentation as it prevents the GC from moving the object, so use it sparingly.
staticNewWeakGcHandle
Creates a new GC handle for the provided managed object.
The handle can be stored and later used for retrieving the MonoObject* related to it by calling getObjectFromGCHandle(). This is a weak handle, meaning it will NOT prevent the garbage collector from collecting the object. getObjectFromGCHandle() will return null if the GC collected the object and handle is no longer valid.
staticFreeGcHandle
Frees a GC handle previously allocated with newGCHandle.
staticGetObjectFromGcHandle
Returns a MonoObject from an allocated GC handle.
staticBox
Converts a managed value type into a reference type by boxing it.
staticUnbox
Unboxes a managed object back to a raw value type.
staticValueCopy
Copies the value from to .
This must be a value-type of type . You need to use this form of copying if is a struct that gets passed to managed code and it contains a reference type. This way the GC is informed about the reference in the struct. You can use normal copies otherwise.
staticReferenceCopy
Copies the pointer to a reference type to , ensuring also points to the object.
This needs to be used if is being passed to managed code (e.g. an output parameter in a method). Otherwise normal copies can be used. must be large enough to hold sizeof(MonoObject*).
staticIsSubClassOf
Checks if this class is a sub class of the specified class.
staticIsValueType
Checks is the specified class a value type.
staticGetEnumPrimitiveType
Returns the underlying primitive type for an enum.
staticGetPrimitiveType
Returns the primitive type of the provided class.
staticGetPrimitiveTypeClass
Returns a corresponding primitive class type based on the provided enum.
staticGetPrimitiveTypeClass
Returns a corresponding primitive class type based on the provided name (e.g. float, int, bool, etc.)
staticBindGenericParameters
Binds parameters to a generic class, and returns a new instantiable class with the bound parameters.
staticGetGenericParameters
Returns the generic parameters of the provided type. must be a pre-allocated buffer able to hold the class types for each parameter.
If is null, then will be populated with the number of available parameters.
staticGetGenericParameters
Returns the generic parameters of the provided type. must be a pre-allocated buffer able to hold the class types for each parameter.
If is null, then will be populated with the number of available parameters.
staticGetUint16Class
Returns Mono class for a 16-bit unsigned integer.
staticGetInt16Class
Returns Mono class for a 16-bit signed integer.
staticGetUint32Class
Returns Mono class for a 32-bit unsigned integer.
staticGetInt32Class
Returns Mono class for a 32-bit signed integer.
staticGetUint64Class
Returns Mono class for a 64-bit unsigned integer.
staticGetInt64Class
Returns Mono class for a 32-bit signed integer.
staticGetFloatClass
Returns Mono class for a floating point number.
staticGetDoubleClass
Returns Mono class for a double floating point number.
staticThrowIfException
staticThrowIfException
Throws a native exception if the provided object is a valid managed exception.