cohtml.CohtmlView
A component allowing you to render an HTML page and perform operations on it such as resizing, sending input events, navigating to a different URL and more.
Inherits from MonoBehaviour
Public Types
| Name | |
|---|---|
| enum class | RenderMode { Unknown, OnScreen, InWorld, InScreenCanvas, InWorldCanvas} A group of constants representing in what mode the CohtmlView should be rendered. |
| enum class | DrawState { Disabled, Advanced, Drawn} Represents the state of the rendering draw process. |
Public Functions
| Name | |
|---|---|
| void | Resize(int width, int height) Resize the view to the specified width and height. |
| bool | GetCamSize(out int width, out int height) Returns the camera dimensions of the current view. |
| Vector2 | ViewToCamSizeRatio() Returns the ratio between the view size and camera size. |
| void | AddRawImageIfMissing() Adds a RawImage component if it’s missing. Used when rendering the CohtmlView component within a Unity3D Canvas UI. |
| void | AttachToRenderer() |
| void | DetachFromRenderer() |
| void | Dispose() |
| void | DestroyNativeView() Destroys the Native View and all its components in the correct order. To ensure proper destruction, the necessary steps must be executed in this order. |
| void | MarkViewRendererForDestroy() Sends a request to the Plugin API to destroy the NativeView Renderer. This step occurs on the render thread, different from the main thread. |
| void | CreateNativeView() Creates a native View object. |
| void | RecreateRenderTargets() Creates an internal ViewRenderer |
| void | AddMissingWorldViewComponents() Adds a Quad MeshFilter, MeshRenderer and MeshCollider components if they are missing. |
Protected Functions
| Name | |
|---|---|
| virtual void | OnEnable() |
| virtual void | Start() |
| virtual void | Update() |
| virtual void | OnWillRenderObject() |
| virtual void | OnDestroy() When destroying Cohtml components, it must follow a specific order - firstly Views then Systems then Library. CohtmlView component must first UnloadDocument, then destroy the native View, and only after that, it’s safe to destroy Unity-related objects and components. |
Public Properties
| Name | |
|---|---|
| CohtmlUISystem | CohtmlUISystem Gets or sets the UI System used by this view |
| string | Page Gets or sets the URL of the view |
| int | Width Gets or sets the width of the view. |
| int | Height Gets or sets the height of the view. |
| bool | EnableComplexSelectors Gets or sets a value indicating whether this view supports complex CSS selectors. |
| bool | IsTransparent Gets or sets a value indicating whether this view supports transparency. |
| bool | PixelPerfect If checked, the view will use the camera’s width and height |
| CameraEvent | CameraEvent Specifies the Camera Event at which the Cohtml CommandBuffer is executed. |
| bool | EnableBackdropFilter If checked, the view elements with the backdrop filter will be able to filter content from the scene. |
| bool | EnableGlobalBackdropFilter If checked, the view elements with the backdrop filter will be able to filter content from the scene. |
| int | BlurRadius Gets or sets the blur radius used for the backdrop filter. Controls how many neighboring pixels are sampled during the blur pass. Larger values result in a stronger blur effect but are more expensive to compute. The value is only applied if m_EnableGlobalBackdropFilter is enabled. Otherwise, assignments are ignored. |
| bool | EnableUISurfacePartitioning Gets or sets a value indicating whether this view is in UI Surface Partitioning Mode. UISurfacePartitioning works only In-Canvas and On-Screen and all other rendering APIs except Vulkan, where texture recording occurs at the PostRender event. |
| bool | EnableHdr If checked, the view will use 16 bit textures for all intermediate render targets |
| RenderMode | RenderingMode Returns the RenderMode used to draw the CohtmlView. |
| RawImage | RawImage Returns the RawImage component if the CohtmlView is rendered inside Unity3D Canvas UI. |
| bool | RaycastTarget Determines whether this view receives input. This property is ignored when AutoFocus is enabled. AutoFocus will be disabled if you set this property. All automatic processing and reading of this property is done in the LateUpdate() / OnGUI() callbacks in Unity, letting you do all your logic for View focus in Update(). |
| bool | EnableBindingAttribute Gets or sets a value indicating whether this CohtmlView enables usage of the CoherentMethod attribute in components in the host GameObject. When true, all the components in the host GameObject are inspected for the CoherentMethod attribute (in the Start function) and the decorated methods are automatically bound when the ReadyForBindings event is received. |
| Camera | RenderingCamera Gets the camera the view is rendering on or null if the view is rendered on a surface. |
| View | NativeView Gets the underlying View instance. |
| ViewListener | Listener Gets the view listener. |
| TextInputHandler | TextInputHandler Gets the text input handler. |
| RenderTexture | ViewTexture Returns the texture used to draw the CohtmlView. |
| AudioSource | AudioSource Gets or sets the AudioSource for the CohtmlView. |
Public Attributes
| Name | |
|---|---|
| const int | DefaultWidth The default Width of the CohtmlView. |
| const int | DefaultHeight The default Height of the CohtmlView. |
| Func< ViewSettings, ViewSettings > | OnViewSettingsOverride Allows modifying the settings of a CohtmlView upon creation. |
| uint | Id The native identification number of the CohtmlView component. |
| View | View Gets the underlying View instance. |
| Material | ViewTextureMaterial Returns the Material object used to render the CohtmlView component. |
| RenderTexture | BackgroundTexture Returns the background texture used to apply backdrop filter. |
| RenderTexture | MaskTexture Returns the MaskTexture texture used to apply global backdrop filter. |
| RenderTexture | GlobalBackdropTexture Returns the Texture used to apply global backdrop filter mask into. |
| RenderTexture | IntermediateTexture Returns the Intermediate texture used to apply horizontal blur effect. |
| AudioSubscriber | AudioSubscriber Gets the AudioSubscriber for this CohtmlView. |
| ViewRenderer | Renderer |
| Func< ViewListener > | ViewListenerFactoryFunc Creates the ViewListener instance for the view. Change to allow usage of custom ViewListener |
| Func< TextInputHandler > | TextInputHandlerFactoryFunc Creates the TextInputHandler instance for the view. Change to allow usage of custom TextInputHandler |
Public Types Documentation
enum RenderMode
| Enumerator | Value | Description |
|---|---|---|
| Unknown | ||
| OnScreen | ||
| InWorld | ||
| InScreenCanvas | ||
| InWorldCanvas |
A group of constants representing in what mode the CohtmlView should be rendered.
enum DrawState
| Enumerator | Value | Description |
|---|---|---|
| Disabled | Rendering is disabled. No new frame draw requests will be processed until the state is changed back to allow drawing. Useful for scenarios like a GameObject or camera is disabled, or lost game focus. | |
| Advanced | A new frame is being processed for rendering. | |
| Drawn | The UI from the current frame is drawn onto the targeted RenderTexture. The next drawing process expects to be in this draw state in order to continue rendering. |
Represents the state of the rendering draw process.
Public Functions Documentation
function Resize
void Resize(
int width,
int height
)
Resize the view to the specified width and height.
Parameters:
- width New width for the view.
- height New height for the view.
function GetCamSize
bool GetCamSize(
out int width,
out int height
)
Returns the camera dimensions of the current view.
function ViewToCamSizeRatio
Vector2 ViewToCamSizeRatio()
Returns the ratio between the view size and camera size.
function AddRawImageIfMissing
void AddRawImageIfMissing()
Adds a RawImage component if it’s missing. Used when rendering the CohtmlView component within a Unity3D Canvas UI.
function AttachToRenderer
void AttachToRenderer()
function DetachFromRenderer
void DetachFromRenderer()
function Dispose
void Dispose()
function DestroyNativeView
void DestroyNativeView()
Destroys the Native View and all its components in the correct order. To ensure proper destruction, the necessary steps must be executed in this order.
- Releases the resources needed for the loaded page.
- Marks the native view for deletion.
- Destroys the C# View object holding the Native View object.
- Sends a request to the Plugin API to destroy the NativeView Renderer. This step occurs on the render thread, different from the main thread. To avoid improper destruction of Cohtml Native View, please use this method or mimic the steps in this order.
function MarkViewRendererForDestroy
void MarkViewRendererForDestroy()
Sends a request to the Plugin API to destroy the NativeView Renderer. This step occurs on the render thread, different from the main thread.
function CreateNativeView
void CreateNativeView()
Creates a native View object.
function RecreateRenderTargets
void RecreateRenderTargets()
Creates an internal ViewRenderer
function AddMissingWorldViewComponents
void AddMissingWorldViewComponents()
Adds a Quad MeshFilter, MeshRenderer and MeshCollider components if they are missing.
Protected Functions Documentation
function OnEnable
virtual void OnEnable()
function Start
virtual void Start()
function Update
virtual void Update()
function OnWillRenderObject
virtual void OnWillRenderObject()
function OnDestroy
virtual void OnDestroy()
When destroying Cohtml components, it must follow a specific order - firstly Views then Systems then Library. CohtmlView component must first UnloadDocument, then destroy the native View, and only after that, it’s safe to destroy Unity-related objects and components.
Public Property Documentation
property CohtmlUISystem
CohtmlUISystem CohtmlUISystem;
Gets or sets the UI System used by this view
The UI System component
property Page
string Page;
Gets or sets the URL of the view
The loaded URL of view
property Width
int Width;
Gets or sets the width of the view.
The width.
property Height
int Height;
Gets or sets the height of the view.
The height.
property EnableComplexSelectors
bool EnableComplexSelectors;
Gets or sets a value indicating whether this view supports complex CSS selectors.
Exceptions:
- System.ApplicationException Is thrown when the property is modified and the view has already been created
true if view supports complex CSS selectors; otherwise, false.
property IsTransparent
bool IsTransparent;
Gets or sets a value indicating whether this view supports transparency.
Exceptions:
- System.ApplicationException Is thrown when the property is modified and the view has already been created
true if view supports transparency; otherwise, false.
property PixelPerfect
bool PixelPerfect;
If checked, the view will use the camera’s width and height
true if we want to use camera’s width and height; otherwise false.
property CameraEvent
CameraEvent CameraEvent;
Specifies the Camera Event at which the Cohtml CommandBuffer is executed.
property EnableBackdropFilter
bool EnableBackdropFilter;
If checked, the view elements with the backdrop filter will be able to filter content from the scene.
property EnableGlobalBackdropFilter
bool EnableGlobalBackdropFilter;
If checked, the view elements with the backdrop filter will be able to filter content from the scene.
property BlurRadius
int BlurRadius;
Gets or sets the blur radius used for the backdrop filter. Controls how many neighboring pixels are sampled during the blur pass. Larger values result in a stronger blur effect but are more expensive to compute. The value is only applied if m_EnableGlobalBackdropFilter is enabled. Otherwise, assignments are ignored.
property EnableUISurfacePartitioning
bool EnableUISurfacePartitioning;
Gets or sets a value indicating whether this view is in UI Surface Partitioning Mode. UISurfacePartitioning works only In-Canvas and On-Screen and all other rendering APIs except Vulkan, where texture recording occurs at the PostRender event.
Exceptions:
- System.ApplicationException Is thrown when the property is modified and the view has already been created
true if view is in UI Surface Partitioning Mode; otherwise, false.
property EnableHdr
bool EnableHdr;
If checked, the view will use 16 bit textures for all intermediate render targets
true if we want to use 16 bit textures for render targets; otherwise false.
property RenderingMode
RenderMode RenderingMode;
Returns the RenderMode used to draw the CohtmlView.
property RawImage
RawImage RawImage;
Returns the RawImage component if the CohtmlView is rendered inside Unity3D Canvas UI.
property RaycastTarget
bool RaycastTarget;
Determines whether this view receives input. This property is ignored when AutoFocus is enabled. AutoFocus will be disabled if you set this property. All automatic processing and reading of this property is done in the LateUpdate() / OnGUI() callbacks in Unity, letting you do all your logic for View focus in Update().
true if this view receives input; otherwise, false.
property EnableBindingAttribute
bool EnableBindingAttribute;
Gets or sets a value indicating whether this CohtmlView enables usage of the CoherentMethod attribute in components in the host GameObject. When true, all the components in the host GameObject are inspected for the CoherentMethod attribute (in the Start function) and the decorated methods are automatically bound when the ReadyForBindings event is received.
true if usage of the CoherentMethod is enabled; otherwise, false.
property RenderingCamera
Camera RenderingCamera;
Gets the camera the view is rendering on or null if the view is rendered on a surface.
The camera used by the view or null.
property NativeView
View NativeView;
Gets the underlying View instance.
The underlying View instance.
property Listener
ViewListener Listener;
Gets the view listener.
The view listener.
property TextInputHandler
TextInputHandler TextInputHandler;
Gets the text input handler.
The Text input handler.
property ViewTexture
RenderTexture ViewTexture;
Returns the texture used to draw the CohtmlView.
property AudioSource
AudioSource AudioSource;
Gets or sets the AudioSource for the CohtmlView.
The AudioSource component
Public Attributes Documentation
variable DefaultWidth
const int DefaultWidth = 1280;
The default Width of the CohtmlView.
variable DefaultHeight
const int DefaultHeight = 720;
The default Height of the CohtmlView.
variable OnViewSettingsOverride
Func< ViewSettings, ViewSettings > OnViewSettingsOverride;
Allows modifying the settings of a CohtmlView upon creation.
variable Id
uint Id => m_NativeViewId;
The native identification number of the CohtmlView component.
variable View
View View => NativeView;
Gets the underlying View instance.
The underlying View instance.
variable ViewTextureMaterial
Material ViewTextureMaterial => m_ViewTextureMaterial;
Returns the Material object used to render the CohtmlView component.
variable BackgroundTexture
RenderTexture BackgroundTexture => m_BackgroundTexture;
Returns the background texture used to apply backdrop filter.
variable MaskTexture
RenderTexture MaskTexture => m_MaskTexture;
Returns the MaskTexture texture used to apply global backdrop filter.
variable GlobalBackdropTexture
RenderTexture GlobalBackdropTexture => m_GlobalBackdropTexture;
Returns the Texture used to apply global backdrop filter mask into.
variable IntermediateTexture
RenderTexture IntermediateTexture => m_IntermediateTexture;
Returns the Intermediate texture used to apply horizontal blur effect.
variable AudioSubscriber
AudioSubscriber AudioSubscriber => m_AudioSubscriber;
Gets the AudioSubscriber for this CohtmlView.
variable Renderer
ViewRenderer Renderer;
variable ViewListenerFactoryFunc
static Func< ViewListener > ViewListenerFactoryFunc = () => { return new ViewListener(); };
Creates the ViewListener instance for the view. Change to allow usage of custom ViewListener
variable TextInputHandlerFactoryFunc
static Func< TextInputHandler > TextInputHandlerFactoryFunc = () => { return new TextInputHandler(); };
Creates the TextInputHandler instance for the view. Change to allow usage of custom TextInputHandler