added: network scene, networking packages
This commit is contained in:
4177
Assets/Scenes/NetworkTest.unity
Normal file
4177
Assets/Scenes/NetworkTest.unity
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Scenes/NetworkTest.unity.meta
Normal file
7
Assets/Scenes/NetworkTest.unity.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f8c36f656558f24ab6aa5c9f9da5abc
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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": [],
|
||||
|
||||
36
Assets/UserChoices.choices
Normal file
36
Assets/UserChoices.choices
Normal file
@@ -0,0 +1,36 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &1
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 53
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 18cde282a8d045bf9d245fdcfaa7271b, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Unity.Multiplayer.Center.Editor::Unity.Multiplayer.Center.Questionnaire.UserChoicesObject
|
||||
QuestionnaireVersion: 1.3
|
||||
UserAnswers:
|
||||
Answers:
|
||||
- QuestionId: Pace
|
||||
Answers:
|
||||
- Fast
|
||||
- QuestionId: Cheating
|
||||
Answers:
|
||||
- CheatingNotImportant
|
||||
- QuestionId: CostSensitivity
|
||||
Answers:
|
||||
- NoCost
|
||||
- QuestionId: NetcodeArchitecture
|
||||
Answers:
|
||||
- ClientServer
|
||||
- QuestionId: PlayerCount
|
||||
Answers:
|
||||
- 4
|
||||
Preset: 11
|
||||
SelectedSolutions:
|
||||
SelectedHostingModel: 4
|
||||
SelectedNetcodeSolution: 1
|
||||
7
Assets/UserChoices.choices.meta
Normal file
7
Assets/UserChoices.choices.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 731e6deba5850af43971b77f8aa4e0de
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user