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

44 行
1.4 KiB

using UnityEngine;
using System.Threading.Tasks;
using Unity.Services.Lobbies.Apis;
using Unity.Services.Lobbies.Http;
using Unity.Services.Lobbies.Scheduler;
using TaskScheduler = Unity.Services.Lobbies.Scheduler.TaskScheduler;
using Unity.Services.Core;
using Unity.Services.Authentication;
namespace Unity.Services.Lobbies
{
internal class LobbyServiceProvider : IInitializablePackage
{
private static GameObject _gameObjectFactory;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
static void Register()
{
// Pass an instance of this class to Core
var generatedPackageRegistry =
CoreRegistry.Instance.RegisterPackage(new LobbyServiceProvider());
// And specify what components it requires, or provides.
generatedPackageRegistry.DependsOn<IAccessToken>();
;
}
public Task Initialize(CoreRegistry registry)
{
_gameObjectFactory = GameObjectFactory.CreateCoreSdkGameObject();
var httpClient = new HttpClient();
var accessTokenLobbyApi = registry.GetServiceComponent<IAccessToken>();
if (accessTokenLobbyApi != null)
{
LobbyService.LobbyApiClient = new LobbyApiClient(httpClient, accessTokenLobbyApi);
}
return Task.CompletedTask;
}
}
}