Unity Events
The Beam Unity Events component makes it easy to monitor when authentication, streaming, and recording events happen. These events update as your sessions change, making it significantly easier to deal with new streams or recordings.
It is recommended that you attach your logic to these events, rather than constantly requesting the information from the Beam Manager.
Most of the events are self explanatory, such as OnStreamStarted, but a few are worth noting.
All events include a small tooltip in editor to help you get started.
Streaming Events
Streaming events cover when the streams start and stop, as well as when the stream state changes.
If you start a stream, but it fails to actually begin, then your will never receive a stream started event. It is advised to bind interaction/core logic to the stream state events, and visual indicator logic to the stream started/ended events.
Recording Events
Recording events cover everything to do with recording. As you can record when both streaming and locally, they include an accompanying CaptureType
variable which will be either Cloud or Local.
Notably, the RecordingState
variable will operate the same regardless of whether you are recording from a stream or locally.
Photo Events
When capturing a photo you have the option of simply listening to the sate of the capture (whether it succeeded or not), or binding to the actual photo output (as a Texture2D). This allows you to then utilise the captured image within your game, if you so wish.
Capturing and Visual Events
These events are related to when something to do with the underlying capturing logic is changed. When talking about capturing we mean the RenderTexture that is being produced by our Beam Camera.
Whenever the aspect ratio or resolution is changed, old render textures are subsequently removed/deleted. You will want to bind to these events to make sure any previews you use are correctly updated. If you want a ready and working preview, the Director Kit includes a Camera Preview prefab which does just that.
Account and Platform Events
Authentication Changed Event
This fires when you are initially trying to login to an experience and an account.
When you initially start it will be NotAuthenticated
.
If you try to authenticate but there are no experience key or secret set, or the user fails to login, then it will change to Error
.
Loading
is when the authentication request has been started, but there's no device code available yet.
Authenticating
is when the user is trying to login but has not yet done so. The user code will be available to show.
Authenticated
is when the user has successfully logged in and is ready to start streaming.
Platform Status Changed
This fires out a StreamPlatform
object that you can use to see which external platforms the user has started or stopped streaming to. This is only fired when the StartSocialStream
or StopSocialStream
functions are called. It will not be called when initially starting a fresh stream, you will need to access the SessionState.StreamPlatforms
variable.
Do note that you can obtain the user's StreamPlatform
objects before streaming via BeamManager.StreamPlatforms
. Changing these settings before streaming is slightly different and you should refer to the guidance on the Streaming Platforms page.