浏览代码

Add ParrelSync to sample

Show how to use ParrelSync with automatic user switching for clones.
/feat-parrelsync
Ben Randall 2 年前
当前提交
b6a47b6d
共有 5 个文件被更改,包括 29 次插入8 次删除
  1. 21
      Assets/Scripts/GameLobby/Auth/SubIdentity_Authentication.cs
  2. 5
      Assets/Scripts/GameLobby/Game/GameManager.cs
  3. 3
      Assets/Scripts/GameLobby/LobbyRelaySample.asmdef
  4. 1
      Packages/manifest.json
  5. 7
      Packages/packages-lock.json

21
Assets/Scripts/GameLobby/Auth/SubIdentity_Authentication.cs


using System;
using System;
#if UNITY_EDITOR
using UnityEngine;
using ParrelSync;
#endif
namespace LobbyRelaySample.Auth
{

private async void DoSignIn(Action onSigninComplete)
{
await UnityServices.InitializeAsync();
#if UNITY_EDITOR
if (ClonesManager.IsClone())
{
// When using a ParrelSync clone, we'll automatically switch to a different authentication profile.
// This will cause the clone to sign in as a different anonymous user account. If you're going to use
// authentication profiles for some other purpose, you may need to change the profile name.
string customArgument = ClonesManager.GetArgument();
AuthenticationService.Instance.SwitchProfile($"Clone_{customArgument}_Profile");
}
#endif
AuthenticationService.Instance.SignedIn += OnSignInChange;
AuthenticationService.Instance.SignedOut += OnSignInChange;

onSigninComplete?.Invoke();
}
catch
{ UnityEngine.Debug.LogError("Failed to login. Did you remember to set your Project ID under Services > General Settings?");
{ UnityEngine.Debug.LogError("Login failed. Did you remember to set your Project ID under Edit > Project Settings... > Services?");
throw;
}

5
Assets/Scripts/GameLobby/Game/GameManager.cs


private void Awake()
{
// Do some arbitrary operations to instantiate singletons.
#pragma warning disable IDE0059 // Unnecessary assignment of a value
var unused = Locator.Get;
#pragma warning restore IDE0059
Locator.Get.Provide(new Auth.Identity(OnAuthSignIn));
Application.wantsToQuit += OnWantToQuit;
}

3
Assets/Scripts/GameLobby/LobbyRelaySample.asmdef


"GUID:4ebbcb26024b547159a86c39de1a8fa5",
"GUID:3bf5041814073ec4089849c425919d5a",
"GUID:1491147abca9d7d4bb7105af628b223e",
"GUID:3b8ed52f1b5c64994af4c4e0aa4b6c4b"
"GUID:3b8ed52f1b5c64994af4c4e0aa4b6c4b",
"GUID:894a6cc6ed5cd2645bb542978cbed6a9"
],
"includePlatforms": [],
"excludePlatforms": [],

1
Packages/manifest.json


"com.unity.toolchain.win-x86_64-linux-x86_64": "0.1.20-preview",
"com.unity.transport": "1.0.0-pre.9",
"com.unity.ugui": "1.0.0",
"com.veriorpies.parrelsync": "https://github.com/VeriorPies/ParrelSync.git?path=/ParrelSync",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",

7
Packages/packages-lock.json


"com.unity.modules.imgui": "1.0.0"
}
},
"com.veriorpies.parrelsync": {
"version": "https://github.com/VeriorPies/ParrelSync.git?path=/ParrelSync",
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "f45424822189ebd875d864a17d7f03b72eafbff7"
},
"com.unity.modules.ai": {
"version": "1.0.0",
"depth": 0,

正在加载...
取消
保存