cohtml.Utils
Class providing utility methods that are commonly used across the integration code.
Public Classes
Section titled “Public Classes”| Name | |
|---|---|
| class | Application Utility class providing Application methods. |
Public Functions
Section titled “Public Functions”| Name | |
|---|---|
| void | CreateDirectory(string path, bool clean) Creates a directory at specified path. |
| string | CombinePaths(params string [] paths) Combines paths together. |
| string | NormalizeSlashes(this string target) Replaces backward slashes with forward slashes. |
| string | DecodeString(string content) Encodes a string into a range of bytes and then decodes it into a string. |
| string | DecodeString(byte [] content) Decodes a range of bytes from a byte array into a string. |
| byte [] | EncodeString(string content) Encodes a string into a sequence of bytes. |
| uint | GetByteCount(string content) Calculates the number of bytes produced by encoding a set of characters. |
| T | AddMissingComponent< T >(this GameObject go) Adds a component to a given GameObject only if its missing. |
| T | FindObjectByType< T >(bool findAny =false) Wrapper method on top of the original Unity3D one allowing support for multiple engine versions. |
| T [] | FindObjectsByType< T >() Wrapper method on top of the original Unity3D one allowing support for multiple engine versions. |
| void | SetBitState(ref byte bits, int position, bool enabled) Sets the state of a bit at a given position in a byte state machine. |
| bool | GetBitState(byte bits, int position) Gets the state of a bit at a given position in a byte state machine. |
| void | ResetByteState(ref byte bits) Resets the state of all bits in the byte sequence to 0. |
| GraphicsFormat | GetHDRGraphicFormat(bool enableHDR) |
| GraphicsFormat | GetSDRGraphicFormat(bool enableHDR) |
| GraphicsFormat | GetMaskGraphicFormat() |
| void | DestroyMaterial(ref Material materialToDestroy) |
| void | Destroy(UnityEngine.Object objectToDestroy) |
| void | DestroyRenderTexture(ref RenderTexture textureToDestroy) |
Public Attributes
Section titled “Public Attributes”| Name | |
|---|---|
| const string | PackagesStr Holds the name of the packages folder. |
| const string | CohtmlUpmName The name of the cohtml upm package. |
| const byte | DefaultByteMask A default byte mask setting all bits to 0. |
| string | CohtmlUpmPath Returns the path of the cohtml upm package. |
| bool | IsGlesDevice |
Public Functions Documentation
Section titled “Public Functions Documentation”function CreateDirectory
Section titled “function CreateDirectory”static void CreateDirectory( string path, bool clean)Creates a directory at specified path.
Parameters:
- path The path where to create the directory.
- clean A flag whether the directory should be cleaned first if it exists.
function CombinePaths
Section titled “function CombinePaths”static string CombinePaths( params string [] paths)Combines paths together.
function NormalizeSlashes
Section titled “function NormalizeSlashes”static string NormalizeSlashes( this string target)Replaces backward slashes with forward slashes.
function DecodeString
Section titled “function DecodeString”static string DecodeString( string content)Encodes a string into a range of bytes and then decodes it into a string.
function DecodeString
Section titled “function DecodeString”static string DecodeString( byte [] content)Decodes a range of bytes from a byte array into a string.
function EncodeString
Section titled “function EncodeString”static byte [] EncodeString( string content)Encodes a string into a sequence of bytes.
function GetByteCount
Section titled “function GetByteCount”static uint GetByteCount( string content)Calculates the number of bytes produced by encoding a set of characters.
function AddMissingComponent< T >
Section titled “function AddMissingComponent< T >”static T AddMissingComponent< T >( this GameObject go)Adds a component to a given GameObject only if its missing.
Parameters:
- go The GameObject to add the component to.
Template Parameters:
- T The type of the component.
Return: Returns the added component or the already existing one.
function FindObjectByType< T >
Section titled “function FindObjectByType< T >”static T FindObjectByType< T >( bool findAny =false)Wrapper method on top of the original Unity3D one allowing support for multiple engine versions.
Parameters:
- findAny If finding any instance of the type is acceptable, enable this flag for a faster search.
Template Parameters:
- T The object type to find.
Return: Returns the object by the given type if found.
function FindObjectsByType< T >
Section titled “function FindObjectsByType< T >”static T [] FindObjectsByType< T >()Wrapper method on top of the original Unity3D one allowing support for multiple engine versions.
Template Parameters:
- T The object type to find.
Return: Returns an array of the object by the given type if found.
function SetBitState
Section titled “function SetBitState”static void SetBitState( ref byte bits, int position, bool enabled)Sets the state of a bit at a given position in a byte state machine.
Parameters:
- bits A ref to the byte sequence of the state machine.
- position The position of the bit from 0 to 7.
- enabled The new bit state.
function GetBitState
Section titled “function GetBitState”static bool GetBitState( byte bits, int position)Gets the state of a bit at a given position in a byte state machine.
Parameters:
- bits The byte sequence of the state machine.
- position The position of the bit from 0 to 7.
Return: True or false based on the state of the bit.
function ResetByteState
Section titled “function ResetByteState”static void ResetByteState( ref byte bits)Resets the state of all bits in the byte sequence to 0.
Parameters:
- bits The byte sequence to reset.
function GetHDRGraphicFormat
Section titled “function GetHDRGraphicFormat”static GraphicsFormat GetHDRGraphicFormat( bool enableHDR)function GetSDRGraphicFormat
Section titled “function GetSDRGraphicFormat”static GraphicsFormat GetSDRGraphicFormat( bool enableHDR)function GetMaskGraphicFormat
Section titled “function GetMaskGraphicFormat”static GraphicsFormat GetMaskGraphicFormat()function DestroyMaterial
Section titled “function DestroyMaterial”static void DestroyMaterial( ref Material materialToDestroy)function Destroy
Section titled “function Destroy”static void Destroy( UnityEngine.Object objectToDestroy)function DestroyRenderTexture
Section titled “function DestroyRenderTexture”static void DestroyRenderTexture( ref RenderTexture textureToDestroy)Public Attributes Documentation
Section titled “Public Attributes Documentation”variable PackagesStr
Section titled “variable PackagesStr”const string PackagesStr = "Packages";Holds the name of the packages folder.
variable CohtmlUpmName
Section titled “variable CohtmlUpmName”const string CohtmlUpmName = "com.coherent-labs.cohtml";The name of the cohtml upm package.
variable DefaultByteMask
Section titled “variable DefaultByteMask”const byte DefaultByteMask = 0b00000000;A default byte mask setting all bits to 0.
variable CohtmlUpmPath
Section titled “variable CohtmlUpmPath”static string CohtmlUpmPath => CombinePaths(PackagesStr, CohtmlUpmName);Returns the path of the cohtml upm package.
variable IsGlesDevice
Section titled “variable IsGlesDevice”static bool IsGlesDevice => SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3 || SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.OpenGLCore;© 2026 Coherent Labs. All rights reserved.