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.
Discussion
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.
You can access the global singleton instance with the Instance property.
Properties
Name | Description |
---|---|
HasConnections | True if any Room is joined |
Microphone | Unity Component that handles one Microphone where data gets routed through (n) Media |
Rooms | |
OnRoomJoin | Called before an actual room join |
OnRoomJoined | Called after a room is joined successfully |
OnRoomLeave | Called before a room leave |
OnRoomLeft | Called after a room is destroyed |
OnPeerJoined | Called on every Peer that joins the room(s) we're connected to |
OnPeerUserDataChanged | Called on every Peer that updates his UserData in the same room(s) |
OnPeerLeft | Called on every Peer that left in the same room(s) |
OnMediaAdded | Called on every Peer that created a media in the same room(s) |
OnMediaRemoved | Called on every Peer that closed/destroyed one of his own media in the same room(s) |
OnMediaActiveStateChanged | Called on every activity change of a media in the same room(s) |
OnRoomUserDataChanged | Called 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. |
OnMessageReceived | Called on every Peer that received message from a peer by UInt64%5b%5d%2cSystem |
OnConnectionStateChanged | Called on the Room that changed the connection state |
OnCreatedMediaObject | Called if this OdinHandler created a MediaStream that was requested by the MediaQueue |
OnDeleteMediaObject | Called if this OdinHandler destroyed a MediaStream that was closed by a remote peer and was requested by the MediaQueue |
UnityAudioSourceTag | Identify by Unity-Tag to attach a Audio |
Use3DAudio | Enable 3D Audio via preset Odin |
CreatePlayback | Creates Room_OnMediaAdded(System events |
PlaybackAudioMixer | |
PlaybackAudioMixerGroup |
Static Properties
Name | Description |
---|---|
Config | Static reference to the global Unity |
Instance | Singleton reference to this OdinHandler |
Public Methods
Name | Description |
---|---|
GetUserData | |
JoinRoom | Join or create a room by name and attach a Media |
LeaveRoom | Leave and free the Room by name |
AddPlaybackComponent | Tries to identifiy a gameobject by tag to assign the PlaybackComponent |
GetOrCreateMicrophoneStream | Returns the attached Audio |
RoomsSetPositionScale | Configures the allowed 'view' distance for proximity calculation of peers in each room |
RoomsUpdatePosition | Updates the two-dimensional position of our own peer in each room |
UpdateUserData | Updates the Rooms |
GetRoom | Gets the room object from Odin |
GetPeer | Gets the a Peer object from a specified room matching a peer ID |
GetMedia | Get the PlaybackStream of a peer in the room |
GetPeers | Get all remote peers inside a room |
BroadcastMessage | Sends arbitrary data to a all remote peers in all rooms |
GetPlaybackComponents | Gets all Audio across all rooms |
GetPlaybackComponent | Gets a Audio |
DestroyPlaybackComponents | Destroys all Audio instances |