using System; using UnityEngine; namespace Unity.Services.Relay.Scheduler { /// /// A convenience class for creating GameObjects for the SdkCore. /// /// As this uses the Unity API it is not thread-safe and must be called /// from the main thread. /// public static class GameObjectFactory { /// /// Creates a CoreSdk game object, which will contain all components required /// by the SDK. /// /// The CoreSdk game object. public static GameObject CreateCoreSdkGameObject() { var random = new System.Random(); string objectName = "_SdkCore-" + random.Next(0, Int32.MaxValue); var gameObject = new GameObject(objectName); #if UNITY_WEBGL gameObject.AddComponent(); #else gameObject.AddComponent(); #endif UnityEngine.Object.DontDestroyOnLoad(gameObject); return gameObject; } } }