using System.Threading.Tasks;
namespace Unity.Services.Core
{
///
/// Utility to initialize all Unity services from a single endpoint.
///
public static class UnityServices
{
internal static IUnityServices Instance { get; set; }
///
/// Initialization state.
///
public static ServicesInitializationState State => Instance?.State ?? ServicesInitializationState.Uninitialized;
///
/// Single entry point to initialize all used services.
///
///
/// Return a handle to the initialization operation.
///
public static Task Initialize()
{
return Initialize(new InitializationOptions());
}
///
/// Single entry point to initialize all used services.
///
///
/// The options to customize services initialization.
///
///
/// Return a handle to the initialization operation.
///
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);
}
}
}