ICohtmlPlugin

More…

#include <ICohtmlPlugin.h>

Inherits from IModuleInterface

Public Classes

Name
structCustomMaterialDrawParams

Public Functions

Name
ICohtmlPlugin &Get()
boolIsAvailable()
DECLARE_DELEGATE_OneParam(FOnURLRequest , FURLWithFallbacks & )
DECLARE_DELEGATE_TwoParams(FOnUserImageDropped , void * , void * )
DECLARE_DELEGATE_OneParam(FOnGetFallbackFormats , TArray< FOverridableFallbackFormat > & )
DECLARE_DELEGATE_RetVal(ICohtmlSpeechSynthesizer * , FOnGetSpeechSynthesizer )
DECLARE_DELEGATE_RetVal(cohtml::ILocalizationManager * , FOnGetLocalizationManager )
DECLARE_DELEGATE_FourParams(FOnShowVirtualKeyboard , TSharedPtr< FCohtmlVirtualKeyboardEntry > & , int32 , cohtml::View * , cohtml::IInputProxy * )
DECLARE_DELEGATE_RetVal(FCohtmlFileHandler * , FOnGetFileHandler )
DECLARE_DELEGATE_RetVal(cohtml::ITextTransformationManager * , FOnGetTextTransformationManager )
DECLARE_DELEGATE_RetVal(TSharedPtr< FCohtmlInputPreprocessor > , FOnGetCohtmlInputPreprocessor )
DECLARE_DELEGATE_RetVal(cohtml::IInternationalizationManager * , FOnGetInternationalizationManager )
DECLARE_DELEGATE_RetVal(cohtml::IFileSystemWriter * , FOnGetFileSystemWriter )
DECLARE_DELEGATE_RetVal(CohtmlTimeFunctionData , FOnGetIncreasingTimeRequestFunc )
DECLARE_DELEGATE_RetVal_OneParam(UMaterialInterface * , FOnMapMaterialName , const FString & )
DECLARE_DELEGATE_OneParam(FOnGetResourceHostLocations , TArray< FResourceHostPair > & )
DECLARE_DELEGATE_RetVal_OneParam(UHUDSurfacePartitioningCompositor * , FOnGetHUDCompositor , UCohtmlHUD * )
DECLARE_DELEGATE_RetVal_OneParam(UWidgetSurfacePartitioningCompositor * , FOnGetWidgetCompositor , UCohtmlWidget * )
DECLARE_DELEGATE_RetVal(ICohtmlScriptProvider * , FOnGetScriptProvider )
DECLARE_DELEGATE_TwoParams(FOnBindCustomEffectParameters , UMaterialInstanceDynamic * , const CustomMaterialDrawParams & )
DECLARE_DELEGATE_OneParam(FOnResizeOrRecreateTexture , FCohtmlViewWrapper * ViewWrapper)
virtual voidEnableProfiling(bool bEnable =true, FString TraceFilePath =FString(""), ECohtmlTraceEventsLevel TraceLevel =ECohtmlTraceEventsLevel::BasicMarkers) =0

Public Attributes

Name
COHTMLPLUGIN_API FOnURLRequestOnURLRequest
COHTMLPLUGIN_API FOnUserImageDroppedOnUserImageDropped
COHTMLPLUGIN_API FOnGetFallbackFormatsOnGetFallbackFormats
COHTMLPLUGIN_API FOnGetSpeechSynthesizerOnGetSpeechSynthesizer
COHTMLPLUGIN_API FOnGetLocalizationManagerOnGetLocalizationManager
COHTMLPLUGIN_API FOnShowVirtualKeyboardOnShowVirtualKeyboard
COHTMLPLUGIN_API FOnGetFileHandlerOnGetFileHandler
COHTMLPLUGIN_API FOnGetTextTransformationManagerOnGetTextTransformationManager
COHTMLPLUGIN_API FOnGetCohtmlInputPreprocessorOnGetCohtmlInputPreprocessor
COHTMLPLUGIN_API FOnGetInternationalizationManagerOnGetInternationalizationManager
COHTMLPLUGIN_API FOnGetFileSystemWriterOnGetFileSystemWriter
COHTMLPLUGIN_API FOnGetIncreasingTimeRequestFuncOnGetIncreasingTimeRequestFunc
COHTMLPLUGIN_API FOnMapMaterialNameOnMapMaterialName
COHTMLPLUGIN_API FOnGetResourceHostLocationsOnGetResourceHostLocations
COHTMLPLUGIN_API FOnGetHUDCompositorOnGetHUDCompositor
COHTMLPLUGIN_API FOnGetWidgetCompositorOnGetWidgetCompositor
COHTMLPLUGIN_API FOnGetScriptProviderOnGetScriptProvider
COHTMLPLUGIN_API FOnBindCustomEffectParametersOnBindCustomEffectParameters
FOnCohtmlLibraryBeginDestroyOnCohtmlLibraryBeginDestroy

Detailed Description

class ICohtmlPlugin;

The public interface to this module. In most cases, this interface is only public to sibling modules within this plugin.

Public Functions Documentation

function Get

static inline ICohtmlPlugin & Get()

Return: Returns singleton instance, loading the module on demand if needed

Singleton-like access to this module’s interface. This is just for convenience! Beware of calling this during the shutdown phase, though. Your module might have been unloaded already.

function IsAvailable

static inline bool IsAvailable()

Return: True if the module is loaded and ready to use

Checks to see if this module is loaded and ready. It is only valid to call Get() if IsAvailable() returns true.

function DECLARE_DELEGATE_OneParam

DECLARE_DELEGATE_OneParam(
    FOnURLRequest ,
    FURLWithFallbacks & 
)

Parameters:

  • A populated and modifiable structure, containing the URL and all fallbacks

A delegate that is fired on the FIRST request for each resource. Will not be called a second time when the fallback resource is requested. Will not be called twice if we have two Views sharing the resource.

function DECLARE_DELEGATE_TwoParams

DECLARE_DELEGATE_TwoParams(
    FOnUserImageDropped ,
    void * ,
    void * 
)

Parameters:

  • UserData contains passed arbitrary data (if any)
  • TexturePtr contains whatever has been passed to cohtml::IAsyncResourceResponse::UserImageData::Texture

Called in cases where the backend won’t receive a delete texture call for the user image Can be used to decrement reference counters for user image resources.

function DECLARE_DELEGATE_OneParam

DECLARE_DELEGATE_OneParam(
    FOnGetFallbackFormats ,
    TArray< FOverridableFallbackFormat > & 
)

Parameters:

  • A populated and modifiable array, which contains all of the image fallback formats from the Editor settings. Can be empty.

A delegate which you can use for control over the image fallback formats

function DECLARE_DELEGATE_RetVal

DECLARE_DELEGATE_RetVal(
    ICohtmlSpeechSynthesizer * ,
    FOnGetSpeechSynthesizer 
)

Return: A pointer to your SpeechSynthesizer object.

A delegate that is fired to receive your ICohtmlSpeechSynthesizer implementation.

function DECLARE_DELEGATE_RetVal

DECLARE_DELEGATE_RetVal(
    cohtml::ILocalizationManager * ,
    FOnGetLocalizationManager 
)

Return: A pointer to your LocalizationManager object.

A delegate that is fired to receive your custom ILocalizationManager implementation.

function DECLARE_DELEGATE_FourParams

DECLARE_DELEGATE_FourParams(
    FOnShowVirtualKeyboard ,
    TSharedPtr< FCohtmlVirtualKeyboardEntry > & ,
    int32 ,
    cohtml::View * ,
    cohtml::IInputProxy * 
)

A delegate that is fired when a virtual keyboard should be shown on the screen. This gives control over whether to show virtual keyboard for given platform, the options given to the VirtualKeyboardEntry, and the actual implementation of the function showing the virtual keyboard.

function DECLARE_DELEGATE_RetVal

DECLARE_DELEGATE_RetVal(
    FCohtmlFileHandler * ,
    FOnGetFileHandler 
)

Return: A pointer to your CohtmlFileHandler object. The lifetime of the object will be controlled by the plugin, but you can also destroy it via FCohtmlSystemHolder::ResetResourceHandler.

A delegate that is fired to receive your custom CohtmlFileHandler implementation.

function DECLARE_DELEGATE_RetVal

DECLARE_DELEGATE_RetVal(
    cohtml::ITextTransformationManager * ,
    FOnGetTextTransformationManager 
)

Return: A pointer to your TextTransformationManager object.

A delegate that is fired to receive your custom ITextTransformationManager implementation.

function DECLARE_DELEGATE_RetVal

DECLARE_DELEGATE_RetVal(
    TSharedPtr< FCohtmlInputPreprocessor > ,
    FOnGetCohtmlInputPreprocessor 
)

Return: A pointer to your FCohtmlInputPreprocessor-derived object. The FCohtmlSystemHolder will hold a shared pointer to it.

A delegate that is fired to receive your custom FCohtmlInputPreprocessor-derived implementation.

function DECLARE_DELEGATE_RetVal

DECLARE_DELEGATE_RetVal(
    cohtml::IInternationalizationManager * ,
    FOnGetInternationalizationManager 
)

Return: A pointer to your InternationalizationManager object.

A delegate that is fired to receive your custom IInternationalizationManager implementation.

function DECLARE_DELEGATE_RetVal

DECLARE_DELEGATE_RetVal(
    cohtml::IFileSystemWriter * ,
    FOnGetFileSystemWriter 
)

Return: A pointer to your FileSystemWriter object.

A delegate that is fired to receive your custom IFileSystemWriter implementation.

function DECLARE_DELEGATE_RetVal

DECLARE_DELEGATE_RetVal(
    CohtmlTimeFunctionData ,
    FOnGetIncreasingTimeRequestFunc 
)

Return: The MonotonicallyIncreasingTime function and optional user data

A delegate that is fired to receive your monotonically increasing time function data.

function DECLARE_DELEGATE_RetVal_OneParam

DECLARE_DELEGATE_RetVal_OneParam(
    UMaterialInterface * ,
    FOnMapMaterialName ,
    const FString & 
)

Return: A pointer to the UMaterial that will be used for drawing the custom effect.

A delegate fired whenever a custom effect needs to be drawn and a mapping between the effect name and a UMaterial* instance is required.

function DECLARE_DELEGATE_OneParam

DECLARE_DELEGATE_OneParam(
    FOnGetResourceHostLocations ,
    TArray< FResourceHostPair > & 
)

A delegate that is fired during World initialization, for example when starting PIE.

function DECLARE_DELEGATE_RetVal_OneParam

DECLARE_DELEGATE_RetVal_OneParam(
    UHUDSurfacePartitioningCompositor * ,
    FOnGetHUDCompositor ,
    UCohtmlHUD * 
)

Parameters:

  • - The HUD that is creating the Compositor.

Return: A pointer your own overriding object. It is good to set the provided UCohtmlHUD as the owner to your newly created object, to prevent it from being garbage collected by the Engine.

A delegate fired whenever a HUD is creating its Surface Partitioning Compositor. You can use this to provide your own override to the UHUDSurfacePartitioningCompositor class.

function DECLARE_DELEGATE_RetVal_OneParam

DECLARE_DELEGATE_RetVal_OneParam(
    UWidgetSurfacePartitioningCompositor * ,
    FOnGetWidgetCompositor ,
    UCohtmlWidget * 
)

Parameters:

  • - The Widget that is creating the Compositor.

Return: A pointer your own overriding object. It is good to set the provided UCohtmlWidget as the owner to your newly created object, to prevent it from being garbage collected by the Engine.

A delegate fired whenever a Widget is creating its Surface Partitioning Compositor. You can use this to provide your own override to the UWidgetSurfacePartitioningCompositor class.

function DECLARE_DELEGATE_RetVal

DECLARE_DELEGATE_RetVal(
    ICohtmlScriptProvider * ,
    FOnGetScriptProvider 
)

Return: A pointer to your own overriding object or nullpt if no provider is available.

You can use this delegate to specify a ScriptProvider object to handle loading of pre-compiled JavaScript data. This can be the default FCohtmlScriptProvider object or your own implementation of the ICohtmlScriptProvider interface. The delegate will be fired on every resource request to check if there is an existing provider to potentially query for compiled script data. If at some point your ScriptProvider is no longer needed, you can just return nullptr here or unbind the delegate.

function DECLARE_DELEGATE_TwoParams

DECLARE_DELEGATE_TwoParams(
    FOnBindCustomEffectParameters ,
    UMaterialInstanceDynamic * ,
    const CustomMaterialDrawParams & 
)

An optional delegate fired whenever a custom effect should bind additional custom properties. The provided arguments are the UMaterialInstanceDynamic that will be used, along with the custom parameters coming from the HTML page.

function DECLARE_DELEGATE_OneParam

DECLARE_DELEGATE_OneParam(
    FOnResizeOrRecreateTexture ,
    FCohtmlViewWrapper * ViewWrapper
)

Optional event that can be used to execute custom code after a ViewWrapper’s render target texture has been created and/or resized.

function EnableProfiling

virtual void EnableProfiling(
    bool bEnable =true,
    FString TraceFilePath =FString(""),
    ECohtmlTraceEventsLevel TraceLevel =ECohtmlTraceEventsLevel::BasicMarkers
) =0

Parameters:

  • bEnable - Enables or disables the emission of internal profile markers
  • TraceFilePath - For platforms using minitrace, the path to the JSON file to write to. Defaults to Game/Saved/Cohtml/profiling.
  • TraceLevel - the granularity and detail of the markers to emit

An API for enabling Cohtml profile markers (usable only with libraries in Development configuration)

Public Attributes Documentation

variable OnURLRequest

static COHTMLPLUGIN_API FOnURLRequest OnURLRequest;

Override this to change the fallback paths for image resources. By changing the contents of the referenced parameter you can inject your own fallback paths, add/remove fallbacks dynamically, etc. You can even change the URL that is currently being loaded. The StartupModule method of your GameModule class is a convenient place to bind your function.

variable OnUserImageDropped

static COHTMLPLUGIN_API FOnUserImageDropped OnUserImageDropped;

Override this before the cohtml::System creation.

variable OnGetFallbackFormats

static COHTMLPLUGIN_API FOnGetFallbackFormats OnGetFallbackFormats;

Use this to inject your own Fallback Formats. Useful for anything that the similar editor option lacks, such as having different fallbacks for different platforms or deciding dynamically which fallbacks you want to use during startup. Will get called once during the initialization of the Cohtml system The StartupModule method of your GameModule class is a convenient place to bind your function.

variable OnGetSpeechSynthesizer

static COHTMLPLUGIN_API FOnGetSpeechSynthesizer OnGetSpeechSynthesizer;

Use this to override the default SpeechSynthesizer. Bind this delegate to a function that returns a pointer to your own implementation. The binding must be done before the CohtmlSystem initialization and the implementation must adhere to the restrictions outlined in the ICohtmlSpeechSynthesizer interface header. The StartupModule method of your GameModule class is a convenient place to bind your function.

variable OnGetLocalizationManager

static COHTMLPLUGIN_API FOnGetLocalizationManager OnGetLocalizationManager;

Use this to override the default Localization Manager. Bind this delegate to a function that returns a pointer to your own implementation. The binding must be done before the CohtmlSystem initialization and the implementation must adhere to the restrictions outlined in the ILocalizationManager interface header. The StartupModule method of your GameModule class is a convenient place to bind your function.

variable OnShowVirtualKeyboard

static COHTMLPLUGIN_API FOnShowVirtualKeyboard OnShowVirtualKeyboard;

Use this to override the default ShowVirtualKeyboard behavior. Bind this delegate to a function that creates new TSharedPtr of FCohtmlVirtualKeyboardEntry or inherited class (should be stored inside the supplied reference of the same type) and showing the virtual keyboard using that virtual keyboard entry. To disable virtual keyboard for specific platform, just leave the implementation of the bound function empty for the given platform. The binding must be done before the CohtmlSystem initialization. The StartupModule method of your GameModule class is a convenient place to bind your function.

variable OnGetFileHandler

static COHTMLPLUGIN_API FOnGetFileHandler OnGetFileHandler;

Use this to override the default File Handler. Bind a function that returns a pointer to your own implementation. The binding must be done before the CohtmlSystem initialization and the implementation must follow the guidelines outlined in the FCohtmlFileHandler/IAsyncResourceHandler headers. The StartupModule method of your GameModule class is a convenient place to bind this function.

variable OnGetTextTransformationManager

static COHTMLPLUGIN_API FOnGetTextTransformationManager OnGetTextTransformationManager;

Use this to override the default Text Transformation Manager. Bind a function that returns a pointer to your own implementation. The binding must be done before the CohtmlSystem initialization and the implementation must adhere to the restrictions outlined in the ITextTransformationManager interface header. The StartupModule method of your GameModule class is a convenient place to bind your function.

variable OnGetCohtmlInputPreprocessor

static COHTMLPLUGIN_API FOnGetCohtmlInputPreprocessor OnGetCohtmlInputPreprocessor;

Use this to override the default implementation of the FCohtmlInputPreprocessor. Bind a function that returns a pointer to your own implementation. The binding must be done before the CohtmlSystem initialization.

variable OnGetInternationalizationManager

static COHTMLPLUGIN_API FOnGetInternationalizationManager OnGetInternationalizationManager;

Use this to override the default Internationalization Manager. Bind a function that returns a pointer to your own implementation. The binding must be done before the CohtmlSystem initialization and the implementation must adhere to the restrictions outlined in the IInternationalizationManager interface header. The StartupModule method of your GameModule class is a convenient place to bind your function.

variable OnGetFileSystemWriter

static COHTMLPLUGIN_API FOnGetFileSystemWriter OnGetFileSystemWriter;

Use this to override the default File System Writer. Bind a function that returns a pointer to your own implementation. The binding must be done before the CohtmlSystem initialization and the implementation must adhere to the restrictions outlined in the IFileSystemWriter interface header. The StartupModule method of your GameModule class is a convenient place to bind your function.

variable OnGetIncreasingTimeRequestFunc

static COHTMLPLUGIN_API FOnGetIncreasingTimeRequestFunc OnGetIncreasingTimeRequestFunc;

Use this to override the default OnMonotonicallyIncreasingTimeRequest function. This function is called by Cohtml during Advance, when accurate current time is needed. Bind a function that returns a pointer to your own implementation. The binding must be done before the CohtmlSystem initialization. The StartupModule method of your GameModule class is a convenient place to bind your function, as shown in the CoherentSample implementation.

variable OnMapMaterialName

static COHTMLPLUGIN_API FOnMapMaterialName OnMapMaterialName;

Required to be bound if custom effects are used. Bind a function that returns a UMaterial* corresponding to the string name passed in as an argument to the delegate. Binding can be done at any point before the system advances, but it’s usually good practice to do that before the initialization of the CohtmlSystem. The StartupModule method of your GameModule class is a convenient place to bind your function. Note that the implementation will be used for all CoHTML Views. At this moment there is no way to have different material mappings on a per-view basis. You’ll need to differentiate entirely by the effect name.

variable OnGetResourceHostLocations

static COHTMLPLUGIN_API FOnGetResourceHostLocations OnGetResourceHostLocations;

Bind this to change the Host locations for resources. By changing the contents of the referenced parameter you can modify the existing hosts or add your own. You can also construct locations dynamically, for example using the FPaths static methods, querying the OS or a server for locations, etc. The StartupModule method of your GameModule class is a convenient place to bind your function.

variable OnGetHUDCompositor

static COHTMLPLUGIN_API FOnGetHUDCompositor OnGetHUDCompositor;

variable OnGetWidgetCompositor

static COHTMLPLUGIN_API FOnGetWidgetCompositor OnGetWidgetCompositor;

variable OnGetScriptProvider

static COHTMLPLUGIN_API FOnGetScriptProvider OnGetScriptProvider;

variable OnBindCustomEffectParameters

static COHTMLPLUGIN_API FOnBindCustomEffectParameters OnBindCustomEffectParameters;

Optional event that can be used to employ binding of additional parameters that the HTML provides when using custom effects. Use the UMaterialInstanceDynamic APIs (e.g. SetTextureParameterValue, SetScalarParameterValue, etc.) to set the appropriate Material parameters based on the values that the event provides.

variable OnCohtmlLibraryBeginDestroy

FOnCohtmlLibraryBeginDestroy OnCohtmlLibraryBeginDestroy;

An event that is fired when the CohtmlLibrary is about to be destroyed. You can use this to clean up any leftover resources you may have allocated.