This is an old revision of the document!
Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorVRHud
Behavior element behavior adding VR Heads-Up Display (HUD) support to actor.
This behavior works similar to ECBehaviorRenderablePanel but shows the content on the VR HUD canvas overlay instead of a dynamic skin. The VR HUD canvas overlay is a canvas displayed on top of the VR view using a user defined field of view. This avoids the developer guessing the best field of view to render the HUD content. This also ensures users can adjust the HUD field of view to their personal preferences easily.
The behavior allows other behaviors to add their content Widget to the Panel separating logic for reuse. This also allows to use the full power of the GUI ToolKit including using GuiThemes to create complex content easily.
To use this behavior add it to the element class (typically BaseVRActorClass) and set the designer selector and GuiTheme to use for the Panel. Now you can add other behaviors targeting the ECBehaviorVRHud to add Widget resources to. You can also add and remove panels manually at runtime.
The Panel is created with a default size of 1024×1024 . You can change the size using the element property to fit the HUD size to your needs. The size should be should be square to avoid stretching.
Element class properties have the prefix vrHud.
The dimensions of the HUD panel in pixels.
vrHud.size1024, 1024<point name='vrHud.size' x='1024' y='1024'/>
The gui Theme to use for rendering the HUD panel content.
vrHud.guiTheme/shareddata/guithemes/modern/modern.degt<string name='vrHud.guiTheme'>/shareddata/guithemes/modern/modern.degt</string>
The designer selector to apply to the HUD panel for custom styling.
vrHud.designerSelectorVRHudPanel<string name='vrHud.designerSelector'>VRHudPanel</string>
This behavior does not use persistency.
Since DragonScript Module Version 1.0
The following example creates an element class with a VR HUD.
class MyElement extends BehaviorElementClass func new() var ECBehaviorVRHud vrHud = ECBehaviorVRHud.new(this, null) vrHud.addContentCreator(ECBehaviorVRHud.BlockContentCreator.new(block ECBehaviorVRHud.Instance instance var Panel panel = instance.getPanel() // Add widgets to the panel here end)) end end
Using element class supporting adding behaviors the behavior can be added like this:
<?xml version='1.0' encoding='UTF-8'?> <elementClass name='MyClass' class='GenericBehaviorElement'> <behavior type='ECBehaviorVRHud'> <point name='.size' x='1024' y='1024'/> <string name='.guiTheme'>/shareddata/guithemes/modern/modern.degt</string> <string name='.designerSelector'>VRHudPanel</string> </behavior> </elementClass>