added: network scene, networking packages
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Codice.Client.Common.WebApi;
|
||||
using Sirenix.OdinInspector;
|
||||
using Unity.Netcode;
|
||||
using Unity.Netcode.Transports.UTP;
|
||||
using Unity.Services.Authentication;
|
||||
using Unity.Services.Relay;
|
||||
using Unity.Services.Relay.Models;
|
||||
using Unity.Services.Core;
|
||||
|
||||
public class SessionManager : MonoBehaviour{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
@@ -11,5 +19,19 @@ public class SessionManager : MonoBehaviour{
|
||||
void Update(){
|
||||
|
||||
}
|
||||
|
||||
[Button]
|
||||
public async Task<string> StartHostWithRelay(int maxConnections, string connectionType)
|
||||
{
|
||||
await UnityServices.InitializeAsync();
|
||||
if (!AuthenticationService.Instance.IsSignedIn)
|
||||
{
|
||||
await AuthenticationService.Instance.SignInAnonymouslyAsync();
|
||||
}
|
||||
var allocation = await RelayService.Instance.CreateAllocationAsync(maxConnections);
|
||||
NetworkManager.Singleton.GetComponent<UnityTransport>().SetRelayServerData(AllocationUtils.ToRelayServerData(allocation, connectionType));
|
||||
var joinCode = await RelayService.Instance.GetJoinCodeAsync(allocation.AllocationId);
|
||||
return NetworkManager.Singleton.StartHost() ? joinCode : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,11 @@
|
||||
"GUID:d8b63aba1907145bea998dd612889d6b",
|
||||
"GUID:4307f53044263cf4b835bd812fc161a4",
|
||||
"GUID:e0cd26848372d4e5c891c569017e11f1",
|
||||
"GUID:1826c0224c0d048b88112c79bbb0cd85"
|
||||
"GUID:1826c0224c0d048b88112c79bbb0cd85",
|
||||
"GUID:f2d49d9fa7e7eb3418e39723a7d3b92f",
|
||||
"GUID:5540e30183c82e84b954c033c388e06c",
|
||||
"GUID:fe25561d224ed4743af4c60938a59d0b",
|
||||
"GUID:37e17ffe38d86ae48bc3207e83ffef88"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
||||
Reference in New Issue
Block a user