{{tag>dragonscript behavior}} [[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[dragengine:modules:dragonscript:abstractions|Abstraction Layers: How you want to build your Game]] >> [[dragengine:modules:dragonscript:behavior_elements|Behavior Elements]] >> **ECBehaviorVRHud** * [[behaviors_use_cases|Behaviors Explained: By Use-Case]] * [[behaviors_a_to_z|Behaviors Explained: From A to Z]] ====== ECBehaviorVRHud ====== Behavior element behavior adding VR Heads-Up Display (HUD) support to actor. This behavior works similar to [[behavior_renderablepanel|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 1024x1024 . You can change the size using the element property to fit the HUD size to your needs. The size of the Hud is always square to avoid stretching. ====== Element Class Properties ====== Element class properties have the prefix ''vrHud.'' ===== size ===== The dimensions of the HUD panel in pixels. * Full name: ''vrHud.size'' * Type: integer * Default Value: ''1024'' * Example (*.deeclass): 1024 ===== guiTheme ===== The [[dragengine:modules:dragonscript:guitheme|gui Theme]] to use for rendering the HUD panel content. * Full name: ''vrHud.guiTheme'' * Type: GuiTheme path * Default value: ''/shareddata/guithemes/modern/modern.degt'' * Example (*.deeclass): /shareddata/guithemes/modern/modern.degt ===== designerSelector ===== The [[dragengine:modules:dragonscript:xmlguitheme:widgetdesigner|designer selector]] to apply to the HUD panel for custom styling. * Full name: ''vrHud.designerSelector'' * Type: string * Default value: ''VRHudPanel'' * Example (*.deeclass): VRHudPanel ====== Optional Behaviors ====== * [[behavior_playercontrollable|ECBehaviorPlayerControllable]]: HUD activates automatically when player takes control if present. ====== Persistency ====== This behavior does not use persistency. ====== API Documentation ====== #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorVRHud.html,ECBehaviorVRHud~@#. Since DragonScript Module Version ''1.0'' ====== Element Class Example ====== 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 ====== Behavior Factory ====== Using element class supporting adding behaviors the behavior can be added like this: 1024 /shareddata/guithemes/modern/modern.degt VRHudPanel ====== Live Examples ====== * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]: ExampleVR project.