This is the main point of control for the Hyperbeam API in WebGL. It provides important methods to the JSLib and is REQUIRED in order for the API to function properly. Attach this script directly to a game object and call StartHyperbeamStream to use.


Events


OnHyperbeamStart

UnityEvent OnHyperbeamStart

Will notify any registered handlers when the Instance property is usable. It is eventually called by StartHyperbeamStream usually before OnTextureReady is invoked.


OnTextureReady

Action<Texture2D> OnTextureReady

Will notify any registered handlers when the Hyperbeam Stream’s texture is ready. It is eventually called after StartHyperbeamStream


OnControlReturned

UnityEvent OnControlReturned

Will notify any registered handlers when control is returned to unity after being handed off by PassControlToBrowser


Properties

Instance
Hyperbeam

The instance of the core Hyperbeam object associated with this controller. Allows access to many of the control methods for interacting with the virtual browser. See Hyperbeam for more info

Volume
float

Sets the stream’s volume. A convience accessor for Instance.Volume

Paused
bool

Pauses the video stream, but not the audio stream. A convience accessor for Instance.SetVideoPause(value)

Methods


StartHyperbeamStream

void StartHyperbeamStream(string embedUrl)

Bootstraps the hyperbeam browser. This will hand off execution the web browsers Javascript runtime in order to setup the stream.

Method Parameters

embedUrl
string
A URL provided by the Hyperbeam REST API

PassControlToBrowser

void PassControlToBrowser(string closeKey, bool ctrl, bool meta, bool alt, bool shift)

Stops unity from intercepting keyboard events and will start sending them to the virtual browser. It will listen for the closeKey along with any modifiers and when pressed will return control back to unity, which can be detected via OnControlReturned

Method Parameters

closeKey
string
The Keydown that will trigger unity regaining control
ctrl
bool
Whether or not the ctrl key must be held down to regain control
meta
bool
Whether or not the meta key must be held down to regain control
alt
bool
Whether or not the alt key must be held down to regain control
shift
bool
Whether or not the shift key must be held down to regain control

TakeBackControlFromBrowser

void TakeBackControlFromBrowser()

Forcibly takes control back from the attached Hyperbeam Instance if PassControlToBrowser was called on it. It will unregister any event handlers currently registered.