Immerse

General SDK programming guide

Step 11 of 13 |30 mins

Synchronisation and interaction

Making a build

Logging

The Immerse SDK provides a logging system to make console logs clearer.

The following severity levels are supported:

  • Error
  • Warning
  • Info
  • Trace
  • Debug
// Log an error
Log.Error("ImmerseSDK", "This is an example of an error");

// Log an warning
Log.Warning("ImmerseSDK", "This is an example of an warning");

// Log with formatting
Log.Info("Scene", "State enabled = {0}", _isEnabled);

Filter log severity globally by setting the minimum level on the App object.

The App object log level

📘

Immerse SDK Class Library

More detail available in Log

Singletons

The SDK uses its own implementation of the Singletondesign pattern that is "Unity friendly".

All singletons derive from the SingletonBehaviour component.

var localisationService = SingletonManager.Get<LocalisationService>();
var service = SingletonManager.CreateSingleton<CustomMessageManager>();

When a scene restarts, the SDK will look for all Singletons that implement IRestartable. These singletons will be destroyed if their ShouldDestroyOnRestart property is true.

📘

Immerse SDK Class Library

More detail available in:

SingletonBehaviour

IRestartable .

ShouldDestroyOnRestart

Waiting for the SDK

It is very important to wait for the SDK to initialise before code can access services such as looking up a local user's avatar, or setting the state of an object. This initialisation does not happen over a single frame, so it must wait on a coroutine.

For this purpose a simple coroutine method is provided called WaitForSdkReadyCoroutine

/// <summary>
/// Make the Unity Start method a coroutine, so it can yield while the ImmerseSDK is initialising
/// </summary>
protected virtual IEnumerator Start()
{
    yield return App.WaitForSdkReadyCoroutine(this);
}

📘

Immerse SDK Class Library

More detail available in WaitForSdkReadyCoroutine

Persistent State

The SDK will receive the persistent state of objects and data from the Immerse Platform when it connects; the persistent state is a group of messages that have been sent up to this point (the latest state for each object)

It is recommended that WaitForSdkReadyCoroutine is used, before accessing anything that depends on a persisted state, like Interactable objects or State Synchronisers.

Synchronisation and interaction

Making a build

Updated 3 months ago

General SDK programming guide


Step 11 of 13 |30 mins

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.