cohtml.Net.Library
This class encapsulates the global Cohtml library.
Inherits from SystemIDisposable
Public Functions
Section titled “Public Functions”| Name | |
|---|---|
| virtual void | Dispose() |
| virtual void | StopWorkers() Stops all work happening on auxiliary threads. The developer should call this to break the loops in ExecuteResourceWork and ExecuteLayoutWork and then eventually join the threads. |
| virtual global.System.IntPtr | GetFeatureInterface(uint featureID) Used for acquiring specific feature objects. |
| virtual void | ExecuteWork(WorkType type, WorkExecutionMode mode, int family) Executes Cohtml tasks. Some work in Cohtml has to happen asynchronously which improves performance and the scalability of the solution. The type of work is either Resources (loading, parsing, GC) or Layout. When new work is available, the user is notified through the OnWorkAvailable callback and should make sure that at some point that work is executed. The mode parameter is important to decide if you’ll only do some tasks (WEM_UntilQueueEmpty) or use it with a dedicated thread until the Library lives. Using a dedicated thread (WEM_UntilQuit) is simpler, but offers less control. This method can be called on any thread. |
| virtual void | ExecuteWork(WorkType type, WorkExecutionMode mode) Executes Cohtml tasks. Some work in Cohtml has to happen asynchronously which improves performance and the scalability of the solution. The type of work is either Resources (loading, parsing, GC) or Layout. When new work is available, the user is notified through the OnWorkAvailable callback and should make sure that at some point that work is executed. The mode parameter is important to decide if you’ll only do some tasks (WEM_UntilQueueEmpty) or use it with a dedicated thread until the Library lives. Using a dedicated thread (WEM_UntilQuit) is simpler, but offers less control. This method can be called on any thread. |
| virtual void | EnableProfiling(bool enabled, string file, uint level) Start/Stop the emitting of internal profiling markers. |
| virtual global.System.IntPtr | ReservedMethod(global.System.IntPtr command, global.System.IntPtr data) Reserved method for internal usage. Do not use. |
| virtual ScriptCompiler | CreateScriptCompiler() Creates new ScriptCompiler. Can be used to compile Script files and produce compiled data. Remember to Destroy the compiler instance when you no longer need it. Can return nullptr if not supported by the current scripting engine. |
| virtual GPUMemoryInfo | GetGPUMemoryStats() Get a struct with the GPU memory information for Cohtml resources. This is available only in a Developer configuration, and will return nullptr otherwise Call the Release() method on the returned GPUMemoryInfo to release the memory allocated for the data Waits for style solving generated from previous Advance. Avoid calling it too early. |
| virtual UserGPUMemoryInfo | GetUserGPUMemoryStats() Get a struct with the GPU memory information for user resources. This is available only in a Developer configuration, and will return nullptr otherwise Call the Release() method on the returned UserGPUMemoryInfo to release the memory allocated for the data Waits for style solving generated from previous Advance. Avoid calling it too early. |
| virtual void | ResetGPUMemoryTrackerPeaks() Resets all peaks tracked in the GPU memory tracker to the current state. |
| virtual void | FreeRenderingResources() Frees all rendering resources used by Cohtml across all Systems and Views This method should be called on the render thread. |
| virtual UISystem | CreateSystem(SystemSettings settings) Create a Cohtml System that can hold multiple Views |
| string | GetDefaultUserAgent() Get default User Agent string which can be used to reset view UA. |
| void | HintThreadUsage(WorkType type) This hints Cohtml that the calling thread will be used for certain work. The call is optional and used for profiling purposes only. It is not necessary to call it in a final shipping environment. |
| void | DecodeURLString(string url, uint urlLen, string decoded, uint [] decodedSize) Decodes a URL string substituting any URL-encoded characters (%20, %21 etc.) with their ASCII counterparts i.e. ‘my%20url.html’ -> ‘my url.html’. |
| string | GetBuildSDKVersion() Get a string with the version of the SDK that has been used to build Cohtml library. |
| string | GetLibraryVersion() Get a string with the version of the Cohtml library. |
| void | EnableCSSParserErrorLocations(bool enable) When enabled, adds line, column and file to CSS parser errors at the cost of reduced CSS parsing performance. Enabled by default for Debug builds, disabled by default for Release builds. |
| Library | Initialize(string licenseKey, LibraryParams arg1, IUnityPluginListener listener) Initializes the library with an externally initialized rendering library |
| void | Uninitialize() Uninitializes the Cohtml library |
Protected Attributes
Section titled “Protected Attributes”| Name | |
|---|---|
| bool | swigCMemOwn |
Public Functions Documentation
Section titled “Public Functions Documentation”function Dispose
Section titled “function Dispose”virtual void Dispose()function StopWorkers
Section titled “function StopWorkers”virtual void StopWorkers()Stops all work happening on auxiliary threads. The developer should call this to break the loops in ExecuteResourceWork and ExecuteLayoutWork and then eventually join the threads.
function GetFeatureInterface
Section titled “function GetFeatureInterface”virtual global.System.IntPtr GetFeatureInterface( uint featureID)Used for acquiring specific feature objects.
function ExecuteWork
Section titled “function ExecuteWork”virtual void ExecuteWork( WorkType type, WorkExecutionMode mode, int family)Executes Cohtml tasks. Some work in Cohtml has to happen asynchronously which improves performance and the scalability of the solution. The type of work is either Resources (loading, parsing, GC) or Layout. When new work is available, the user is notified through the OnWorkAvailable callback and should make sure that at some point that work is executed. The mode parameter is important to decide if you’ll only do some tasks (WEM_UntilQueueEmpty) or use it with a dedicated thread until the Library lives. Using a dedicated thread (WEM_UntilQuit) is simpler, but offers less control. This method can be called on any thread.
Parameters:
- type Sets the work type to schedule.
- mode Sets the mode to use in the Execution. Note that WEM_UntilQuit will not return until Cohtml itself is uninitialized.
- family Sets the task family Layout work to execute. Each View has a task family that can be retrieved through View.GetTaskFamilyId. The parameter allows executing work for a specific View, you can also pass COHTML_ANY_TASK_FAMILY_ID, which will execute any Layout work available for all Views.
function ExecuteWork
Section titled “function ExecuteWork”virtual void ExecuteWork( WorkType type, WorkExecutionMode mode)Executes Cohtml tasks. Some work in Cohtml has to happen asynchronously which improves performance and the scalability of the solution. The type of work is either Resources (loading, parsing, GC) or Layout. When new work is available, the user is notified through the OnWorkAvailable callback and should make sure that at some point that work is executed. The mode parameter is important to decide if you’ll only do some tasks (WEM_UntilQueueEmpty) or use it with a dedicated thread until the Library lives. Using a dedicated thread (WEM_UntilQuit) is simpler, but offers less control. This method can be called on any thread.
Parameters:
- type Sets the work type to schedule.
- mode Sets the mode to use in the Execution. Note that WEM_UntilQuit will not return until Cohtml itself is uninitialized.
function EnableProfiling
Section titled “function EnableProfiling”virtual void EnableProfiling( bool enabled, string file, uint level)Start/Stop the emitting of internal profiling markers.
Parameters:
- enabled Whether the profiling should be stopped or started
- file If the profiling is done through minitrace, the path for the JSON file where the profiling messages will be written to.
- level The profiling level 1 or 2. 1 - enables only basic markers, 2 - enables all markers and can negatively impact performance but provides a lot of information
Note: The profiling can be enabled only in Development builds of Cohtml
function ReservedMethod
Section titled “function ReservedMethod”virtual global.System.IntPtr ReservedMethod( global.System.IntPtr command, global.System.IntPtr data)Reserved method for internal usage. Do not use.
function CreateScriptCompiler
Section titled “function CreateScriptCompiler”virtual ScriptCompiler CreateScriptCompiler()Creates new ScriptCompiler. Can be used to compile Script files and produce compiled data. Remember to Destroy the compiler instance when you no longer need it. Can return nullptr if not supported by the current scripting engine.
function GetGPUMemoryStats
Section titled “function GetGPUMemoryStats”virtual GPUMemoryInfo GetGPUMemoryStats()Get a struct with the GPU memory information for Cohtml resources. This is available only in a Developer configuration, and will return nullptr otherwise Call the Release() method on the returned GPUMemoryInfo to release the memory allocated for the data Waits for style solving generated from previous Advance. Avoid calling it too early.
function GetUserGPUMemoryStats
Section titled “function GetUserGPUMemoryStats”virtual UserGPUMemoryInfo GetUserGPUMemoryStats()Get a struct with the GPU memory information for user resources. This is available only in a Developer configuration, and will return nullptr otherwise Call the Release() method on the returned UserGPUMemoryInfo to release the memory allocated for the data Waits for style solving generated from previous Advance. Avoid calling it too early.
function ResetGPUMemoryTrackerPeaks
Section titled “function ResetGPUMemoryTrackerPeaks”virtual void ResetGPUMemoryTrackerPeaks()Resets all peaks tracked in the GPU memory tracker to the current state.
function FreeRenderingResources
Section titled “function FreeRenderingResources”virtual void FreeRenderingResources()Frees all rendering resources used by Cohtml across all Systems and Views This method should be called on the render thread.
function CreateSystem
Section titled “function CreateSystem”virtual UISystem CreateSystem( SystemSettings settings)Create a Cohtml System that can hold multiple Views
Parameters:
- settings the system creation parameters
Return: a native Cohtml system object.
function GetDefaultUserAgent
Section titled “function GetDefaultUserAgent”static string GetDefaultUserAgent()Get default User Agent string which can be used to reset view UA.
function HintThreadUsage
Section titled “function HintThreadUsage”static void HintThreadUsage( WorkType type)This hints Cohtml that the calling thread will be used for certain work. The call is optional and used for profiling purposes only. It is not necessary to call it in a final shipping environment.
Parameters:
- type Sets the work type of this thread.
function DecodeURLString
Section titled “function DecodeURLString”static void DecodeURLString( string url, uint urlLen, string decoded, uint [] decodedSize)Decodes a URL string substituting any URL-encoded characters (%20, %21 etc.) with their ASCII counterparts i.e. ‘my%20url.html’ -> ‘my url.html’.
Parameters:
- url the url string to decode
- urlLen the number of characters in the url
- decoded pointer to the buffer where to copy the decoded string. Can be nullptr in order to query the size of the output
- decodedSize the length of the decoded string, including the terminating null
function GetBuildSDKVersion
Section titled “function GetBuildSDKVersion”static string GetBuildSDKVersion()Get a string with the version of the SDK that has been used to build Cohtml library.
Return: String with the version of the platform SDK
function GetLibraryVersion
Section titled “function GetLibraryVersion”static string GetLibraryVersion()Get a string with the version of the Cohtml library.
Return: String with the version of the Cohtml library
function EnableCSSParserErrorLocations
Section titled “function EnableCSSParserErrorLocations”static void EnableCSSParserErrorLocations( bool enable)When enabled, adds line, column and file to CSS parser errors at the cost of reduced CSS parsing performance. Enabled by default for Debug builds, disabled by default for Release builds.
function Initialize
Section titled “function Initialize”static Library Initialize( string licenseKey, LibraryParams arg1, IUnityPluginListener listener)Initializes the library with an externally initialized rendering library
Parameters:
- licenseKey license key provided by Coherent Labs
- listener The Helper class providing plugin events.
Return: The created library object. Null if the operation is unsuccessful.
Note: you can have only one library active at a time. Use this only when you need to reuse the rendering library.
function Uninitialize
Section titled “function Uninitialize”static void Uninitialize()Uninitializes the Cohtml library
Warning: The last time you call this function you must call it with. Freeing the memory is usually done on application exit so all user allocations are cleared.
Protected Attributes Documentation
Section titled “Protected Attributes Documentation”variable swigCMemOwn
Section titled “variable swigCMemOwn”bool swigCMemOwn;© 2026 Coherent Labs. All rights reserved.