Yield Instructions
It is recommended not to start your experience until after you are authenticated. When using auto authentication, there are events. When authenticating manually, you can await the async methods. Another alternative is to use yield instructions with a coroutine.
This yield instruction waits until reporting has been initialized. Because reporting first requires authentication, we can also assume that the user is authenticated. Note that sending report statements before reporting is initialized will result in those statements being lost.
See below for a basic implementation of the WaitForReporting
yield instruction
using System.Collections;
using ImmerseSDK.Platform.Reporting;
using UnityEngine;
public class WaitForReportingExample : MonoBehaviour
{
private IEnumerator Start()
{
yield return new WaitForImmerseReporting();
// Do something
}
}
When only using the Platform package, the functionality of this yield instruction is the same as WaitForReporting
. However, if used with other packages, this yield instruction will wait also wait for their initialization. e.g. if the Multiplayer package is used, this will wait until the user is connected before resolving.
See below for a basic implementation of the WaitForImmerseReady
yield instruction
using System.Collections;
using ImmerseSDK.Platform;
using UnityEngine;
public class WaitForReadyExample : MonoBehaviour
{
private IEnumerator Start()
{
yield return new WaitForImmerseReady();
// Do something
}
}