added: network scene, networking packages

This commit is contained in:
Chris
2025-09-02 18:43:07 -04:00
parent ae2371a6fa
commit ba0ff08c5a
10 changed files with 4302 additions and 11 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 7f8c36f656558f24ab6aa5c9f9da5abc
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,6 +1,14 @@
using UnityEngine; using UnityEngine;
using System; using System;
using System.Threading.Tasks;
using Codice.Client.Common.WebApi;
using Sirenix.OdinInspector;
using Unity.Netcode;
using Unity.Netcode.Transports.UTP; 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{ public class SessionManager : MonoBehaviour{
// Start is called once before the first execution of Update after the MonoBehaviour is created // 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(){ 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;
}
} }

View File

@@ -10,7 +10,11 @@
"GUID:d8b63aba1907145bea998dd612889d6b", "GUID:d8b63aba1907145bea998dd612889d6b",
"GUID:4307f53044263cf4b835bd812fc161a4", "GUID:4307f53044263cf4b835bd812fc161a4",
"GUID:e0cd26848372d4e5c891c569017e11f1", "GUID:e0cd26848372d4e5c891c569017e11f1",
"GUID:1826c0224c0d048b88112c79bbb0cd85" "GUID:1826c0224c0d048b88112c79bbb0cd85",
"GUID:f2d49d9fa7e7eb3418e39723a7d3b92f",
"GUID:5540e30183c82e84b954c033c388e06c",
"GUID:fe25561d224ed4743af4c60938a59d0b",
"GUID:37e17ffe38d86ae48bc3207e83ffef88"
], ],
"includePlatforms": [], "includePlatforms": [],
"excludePlatforms": [], "excludePlatforms": [],

View 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

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 731e6deba5850af43971b77f8aa4e0de
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -7,11 +7,14 @@
"com.unity.ide.visualstudio": "2.0.23", "com.unity.ide.visualstudio": "2.0.23",
"com.unity.inputsystem": "1.14.2", "com.unity.inputsystem": "1.14.2",
"com.unity.multiplayer.center": "1.0.0", "com.unity.multiplayer.center": "1.0.0",
"com.unity.multiplayer.tools": "2.2.5", "com.unity.multiplayer.center.quickstart": "1.0.1",
"com.unity.netcode.gameobjects": "2.1.1", "com.unity.multiplayer.playmode": "1.6.0",
"com.unity.multiplayer.tools": "2.2.6",
"com.unity.multiplayer.widgets": "1.0.1",
"com.unity.netcode.gameobjects": "2.5.0",
"com.unity.probuilder": "6.0.7", "com.unity.probuilder": "6.0.7",
"com.unity.render-pipelines.universal": "17.2.0", "com.unity.render-pipelines.universal": "17.2.0",
"com.unity.services.multiplayer": "1.1.0", "com.unity.services.multiplayer": "1.1.6",
"com.unity.test-framework": "1.5.1", "com.unity.test-framework": "1.5.1",
"com.unity.timeline": "1.8.9", "com.unity.timeline": "1.8.9",
"com.unity.ugui": "2.0.0", "com.unity.ugui": "2.0.0",

View File

@@ -119,8 +119,27 @@
"com.unity.modules.uielements": "1.0.0" "com.unity.modules.uielements": "1.0.0"
} }
}, },
"com.unity.multiplayer.center.quickstart": {
"version": "1.0.1",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.modules.uielements": "1.0.0",
"com.unity.multiplayer.center": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.multiplayer.playmode": {
"version": "1.6.0",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.nuget.newtonsoft-json": "2.0.2"
},
"url": "https://packages.unity.com"
},
"com.unity.multiplayer.tools": { "com.unity.multiplayer.tools": {
"version": "2.2.5", "version": "2.2.6",
"depth": 0, "depth": 0,
"source": "registry", "source": "registry",
"dependencies": { "dependencies": {
@@ -134,12 +153,21 @@
}, },
"url": "https://packages.unity.com" "url": "https://packages.unity.com"
}, },
"com.unity.netcode.gameobjects": { "com.unity.multiplayer.widgets": {
"version": "2.1.1", "version": "1.0.1",
"depth": 0, "depth": 0,
"source": "registry", "source": "registry",
"dependencies": { "dependencies": {
"com.unity.transport": "2.3.0", "com.unity.services.multiplayer": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.netcode.gameobjects": {
"version": "2.5.0",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.transport": "2.4.0",
"com.unity.nuget.mono-cecil": "1.11.4" "com.unity.nuget.mono-cecil": "1.11.4"
}, },
"url": "https://packages.unity.com" "url": "https://packages.unity.com"
@@ -268,15 +296,15 @@
"url": "https://packages.unity.com" "url": "https://packages.unity.com"
}, },
"com.unity.services.multiplayer": { "com.unity.services.multiplayer": {
"version": "1.1.0", "version": "1.1.6",
"depth": 0, "depth": 0,
"source": "registry", "source": "registry",
"dependencies": { "dependencies": {
"com.unity.transport": "2.2.1", "com.unity.transport": "2.5.0",
"com.unity.collections": "2.2.1", "com.unity.collections": "2.2.1",
"com.unity.services.qos": "1.3.0", "com.unity.services.qos": "1.3.0",
"com.unity.services.core": "1.13.0", "com.unity.services.core": "1.13.0",
"com.unity.services.wire": "1.2.7", "com.unity.services.wire": "1.4.0",
"com.unity.services.deployment": "1.3.0", "com.unity.services.deployment": "1.3.0",
"com.unity.nuget.newtonsoft-json": "3.2.1", "com.unity.nuget.newtonsoft-json": "3.2.1",
"com.unity.modules.unitywebrequest": "1.0.0", "com.unity.modules.unitywebrequest": "1.0.0",

View File

@@ -8,6 +8,9 @@ EditorBuildSettings:
- enabled: 1 - enabled: 1
path: Assets/Scenes/SampleScene.unity path: Assets/Scenes/SampleScene.unity
guid: 99c9720ab356a0642a771bea13969a05 guid: 99c9720ab356a0642a771bea13969a05
- enabled: 1
path: Assets/Scenes/NetworkTest.unity
guid: 7f8c36f656558f24ab6aa5c9f9da5abc
m_configObjects: m_configObjects:
com.unity.input.settings: {fileID: 11400000, guid: e4ca318d34698fe41ba99a765e54e4c2, type: 2} com.unity.input.settings: {fileID: 11400000, guid: e4ca318d34698fe41ba99a765e54e4c2, type: 2}
com.unity.input.settings.actions: {fileID: -944628639613478452, guid: 94c7611bb3f64b248940847af54844cf, type: 3} com.unity.input.settings.actions: {fileID: -944628639613478452, guid: 94c7611bb3f64b248940847af54844cf, type: 3}

View File

@@ -0,0 +1,4 @@
{
"PlayerTags": [],
"version": "1.6.0"
}