您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

37 行
1.1 KiB

using System;
using UnityEngine;
namespace Unity.Services.Lobbies.Scheduler
{
/// <summary>
/// <para>A convenience class for creating GameObjects for the SdkCore.</para>
///
/// <para>As this uses the Unity API it is not thread-safe and must be called
/// from the main thread.</para>
/// </summary>
public static class GameObjectFactory
{
/// <summary>
/// Creates a CoreSdk game object, which will contain all components required
/// by the SDK.
/// </summary>
/// <returns>The CoreSdk game object.</returns>
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<TaskSchedulerWebGL>();
#else
gameObject.AddComponent<TaskSchedulerThreaded>();
#endif
UnityEngine.Object.DontDestroyOnLoad(gameObject);
return gameObject;
}
}
}