Developer Documentation
Our new developer documentation is now available. Please check it out!

OdinHandler

public class OdinHandler : MonoBehaviour

The OdinHandler class is the global ODIN manager within Unity. It’s built as a singleton. Create an empty game object in your scene and add this script to it. OdinHandler uses DontDestroyOnLoad to keep the singleton alive even if the scene changes.

Properties

NameDescription
HasConnectionsTrue if any Room is joined
MicrophoneUnity Component that handles one Microphone where data gets routed through (n) Media
Rooms
OnRoomJoinCalled before an actual room join
OnRoomJoinedCalled after a room is joined successfully
OnRoomLeaveCalled before a room leave
OnRoomLeftCalled after a room is destroyed
OnPeerJoinedCalled on every Peer that joins the room(s) we're connected to
OnPeerUserDataChangedCalled on every Peer that updates his UserData in the same room(s)
OnPeerLeftCalled on every Peer that left in the same room(s)
OnMediaAddedCalled on every Peer that created a media in the same room(s)
OnMediaRemovedCalled on every Peer that closed/destroyed one of his own media in the same room(s)
OnMediaActiveStateChangedCalled on every activity change of a media in the same room(s)
OnRoomUserDataChangedCalled on the Room that updates his UserData. Changing a Room's UserData is only possible via request to Odin server API, but not supported inside the client SDK.
OnMessageReceivedCalled on every Peer that received message from a peer by UInt64%5b%5d%2cSystem
OnConnectionStateChangedCalled on the Room that changed the connection state
OnCreatedMediaObjectCalled if this OdinHandler created a MediaStream that was requested by the MediaQueue
OnDeleteMediaObjectCalled if this OdinHandler destroyed a MediaStream that was closed by a remote peer and was requested by the MediaQueue
UnityAudioSourceTagIdentify by Unity-Tag to attach a Audio
Use3DAudioEnable 3D Audio via preset Odin
CreatePlaybackCreates Room_OnMediaAdded(System events
PlaybackAudioMixer
PlaybackAudioMixerGroup

Static Properties

NameDescription
ConfigStatic reference to the global Unity
InstanceSingleton reference to this OdinHandler

Public Methods

NameDescription
GetUserData
JoinRoomJoin or create a room by name and attach a Media
LeaveRoomLeave and free the Room by name
AddPlaybackComponentTries to identifiy a gameobject by tag to assign the PlaybackComponent
GetOrCreateMicrophoneStreamReturns the attached Audio
RoomsSetPositionScaleConfigures the allowed 'view' distance for proximity calculation of peers in each room
RoomsUpdatePositionUpdates the two-dimensional position of our own peer in each room
UpdateUserDataUpdates the Rooms
GetRoomGets the room object from Odin
GetPeerGets the a Peer object from a specified room matching a peer ID
GetMediaGet the PlaybackStream of a peer in the room
GetPeersGet all remote peers inside a room
BroadcastMessageSends arbitrary data to a all remote peers in all rooms
GetPlaybackComponentsGets all Audio across all rooms
GetPlaybackComponentGets a Audio
DestroyPlaybackComponentsDestroys all Audio instances