User Tools

Site Tools


dragengine:modules:dragonscript:behavior_vrhud

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 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):
    <integer name='vrHud.size'>1024</integer>

guiTheme

The 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):
    <string name='vrHud.guiTheme'>/shareddata/guithemes/modern/modern.degt</string>

designerSelector

The designer selector to apply to the HUD panel for custom styling.

  • Full name: vrHud.designerSelector
  • Type: string
  • Default value: VRHudPanel
  • Example (*.deeclass):
    <string name='vrHud.designerSelector'>VRHudPanel</string>

Optional Behaviors

Persistency

This behavior does not use persistency.

API Documentation

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:

<?xml version='1.0' encoding='UTF-8'?>
<elementClass name='MyClass' class='GenericBehaviorElement'>
	<behavior type='ECBehaviorVRHud'>
		<integer name='.size'>1024</integer>
		<string name='.guiTheme'>/shareddata/guithemes/modern/modern.degt</string>
		<string name='.designerSelector'>VRHudPanel</string>
	</behavior>
</elementClass>

Live Examples

You could leave a comment if you were logged in.
dragengine/modules/dragonscript/behavior_vrhud.txt · Last modified: by dragonlord