您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
1.6 KiB
1.6 KiB
Services Core
This package provides a solution to initialize all game services in a single call and defines common components used by multiple game service packages. These components are standardized and aim to unify the overall experience of working with game service packages.
Installation
To add the Services Core package to your project, please use the Package Manager UI to install the latest version of the package.
Package contents
Initialize game services
To initialize all game services at once you just have to call UnityServices.Initialize()
.
It returns an IAsyncOperation
object to enable you to monitor the initialization's progression.
Using a coroutine
IEnumerator InitializeServicesRoutine()
{
IAsyncOperation servicesInitialization = UnityServices.Initialize();
while (!servicesInitialization.IsDone)
{
yield return null;
}
if (servicesInitialization.Status == AsyncOperationStatus.Succeeded)
{
// All services are now initialized.
}
else
{
// An error occured during services initialization.
}
}
Using a callback
void InitializeServices()
{
UnityServices.Initialize().Completed += servicesInitialization =>
{
if (servicesInitialization.Status == AsyncOperationStatus.Succeeded)
{
// All services are now initialized.
}
else
{
// An error occured during services initialization.
}
};
}
Technical details
Requirements
- Supported Unity Editor: 2019.4 and later.