您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
49 行
1.6 KiB
49 行
1.6 KiB
using System.Threading.Tasks;
|
|
|
|
namespace Unity.Services.Core
|
|
{
|
|
/// <summary>
|
|
/// Utility to initialize all Unity services from a single endpoint.
|
|
/// </summary>
|
|
public static class UnityServices
|
|
{
|
|
internal static IUnityServices Instance { get; set; }
|
|
|
|
/// <summary>
|
|
/// Initialization state.
|
|
/// </summary>
|
|
public static ServicesInitializationState State => Instance?.State ?? ServicesInitializationState.Uninitialized;
|
|
|
|
/// <summary>
|
|
/// Single entry point to initialize all used services.
|
|
/// </summary>
|
|
/// <returns>
|
|
/// Return a handle to the initialization operation.
|
|
/// </returns>
|
|
public static Task Initialize()
|
|
{
|
|
return Initialize(new InitializationOptions());
|
|
}
|
|
|
|
/// <summary>
|
|
/// Single entry point to initialize all used services.
|
|
/// </summary>
|
|
/// <param name="options">
|
|
/// The options to customize services initialization.
|
|
/// </param>
|
|
/// <returns>
|
|
/// Return a handle to the initialization operation.
|
|
/// </returns>
|
|
public static Task Initialize(InitializationOptions options)
|
|
{
|
|
if (Instance == null)
|
|
{
|
|
return Task.FromException(
|
|
new ServicesInitializationException("You are attempting to initialize Unity Services too early." +
|
|
" Please consider to move your initialization logic to happen after RuntimeInitializeLoadType.AfterAssembliesLoaded"));
|
|
}
|
|
|
|
return Instance.Initialize(options);
|
|
}
|
|
}
|
|
}
|