From 8cf600285883b26f0cf8530b78e166216d760aba Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Wed, 20 Mar 2024 15:24:03 +0100 Subject: [PATCH] The networkstarter starts in host mode --- .../Networking/HumanoidPlayer_Editor.cs | 6 +- .../HumanoidControl/Networking/Netcode.meta | 2 +- .../Netcode}/HumanoidNetcode_Editor.cs | 27 ++++----- .../Netcode}/HumanoidNetcode_Editor.cs.meta | 0 Editor/PasserVR.HumanoidControl.Editor.asmdef | 4 +- .../Networking/NetworkingStarter_Editor.cs | 25 +++++--- .../Resources/HumanoidPlayer.prefab | 28 +++++++++ .../Netcode/HumanoidPlayerNetcode.cs | 53 +++++++++-------- .../Networking/Netcode/NetcodeStarter.cs | 59 +++++++++++-------- Runtime/PasserVR.HumanoidControl.asmdef | 3 +- Runtime/Tools/Networking/NetworkingStarter.cs | 7 +++ Samples~.meta | 8 --- 12 files changed, 138 insertions(+), 84 deletions(-) rename Runtime/HumanoidControl/Scripts/Networking/Netcode/Editor.meta => Editor/HumanoidControl/Networking/Netcode.meta (77%) rename {Runtime/HumanoidControl/Scripts/Networking/Netcode/Editor => Editor/HumanoidControl/Networking/Netcode}/HumanoidNetcode_Editor.cs (58%) rename {Runtime/HumanoidControl/Scripts/Networking/Netcode/Editor => Editor/HumanoidControl/Networking/Netcode}/HumanoidNetcode_Editor.cs.meta (100%) delete mode 100644 Samples~.meta diff --git a/Editor/HumanoidControl/Networking/HumanoidPlayer_Editor.cs b/Editor/HumanoidControl/Networking/HumanoidPlayer_Editor.cs index bb3792f..85f51b3 100644 --- a/Editor/HumanoidControl/Networking/HumanoidPlayer_Editor.cs +++ b/Editor/HumanoidControl/Networking/HumanoidPlayer_Editor.cs @@ -1,9 +1,6 @@ using System.Collections.Generic; using UnityEngine; using UnityEditor; -#if !UNITY_2019_1_OR_NEWER -using UnityEngine.Networking; -#endif namespace Passer.Humanoid { @@ -28,6 +25,9 @@ namespace Passer.Humanoid { } public static void UpdateHumanoidPrefab(GameObject prefab, string prefabPath) { + if (prefab == null) + return; + if (!Application.isPlaying) { Debug.Log("UpdateHumanoidPrefab " + Application.isFocused + " " + Application.isBatchMode + " " + Application.isEditor); if (Application.isFocused && !Application.isBatchMode && Application.isEditor) { diff --git a/Runtime/HumanoidControl/Scripts/Networking/Netcode/Editor.meta b/Editor/HumanoidControl/Networking/Netcode.meta similarity index 77% rename from Runtime/HumanoidControl/Scripts/Networking/Netcode/Editor.meta rename to Editor/HumanoidControl/Networking/Netcode.meta index d4f4a97..3a4b5bb 100644 --- a/Runtime/HumanoidControl/Scripts/Networking/Netcode/Editor.meta +++ b/Editor/HumanoidControl/Networking/Netcode.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 2d90d19d1758e7640a802a318b83849a +guid: 1e00cb872f4ac3e4086b96d4e9ccdc7a folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Runtime/HumanoidControl/Scripts/Networking/Netcode/Editor/HumanoidNetcode_Editor.cs b/Editor/HumanoidControl/Networking/Netcode/HumanoidNetcode_Editor.cs similarity index 58% rename from Runtime/HumanoidControl/Scripts/Networking/Netcode/Editor/HumanoidNetcode_Editor.cs rename to Editor/HumanoidControl/Networking/Netcode/HumanoidNetcode_Editor.cs index 716486b..57a1f8b 100644 --- a/Runtime/HumanoidControl/Scripts/Networking/Netcode/Editor/HumanoidNetcode_Editor.cs +++ b/Editor/HumanoidControl/Networking/Netcode/HumanoidNetcode_Editor.cs @@ -1,33 +1,34 @@ using UnityEngine; -#if !UNITY_2019_1_OR_NEWER -using UnityEngine.Networking; -#endif +using UnityEditor; namespace Passer.Humanoid { public class OnLoadHumanoidPlayerNetcode { public static void CheckHumanoidPlayer() { -#if !UNITY_2019_1_OR_NEWER string prefabPath = OnLoadHumanoidPlayer.GetHumanoidPlayerPrefabPath(); GameObject playerPrefab = OnLoadHumanoidPlayer.GetHumanoidPlayerPrefab(prefabPath); -#pragma warning disable 0618 - NetworkManager nwManager = Object.FindObjectOfType(); -#if hNW_UNET +#if hNETCODE + Unity.Netcode.NetworkManager nwManager = Object.FindObjectOfType(); if (nwManager == null) { NetworkingStarter nwStarter = Object.FindObjectOfType(); if (nwStarter != null) - nwManager = nwStarter.gameObject.AddComponent(); + nwManager = nwStarter.gameObject.AddComponent(); } - if (nwManager != null && nwManager.playerPrefab == null) - nwManager.playerPrefab = (GameObject)Resources.Load("HumanoidPlayer"); + Unity.Netcode.NetworkConfig nwConfig = nwManager.NetworkConfig; + if (nwConfig.NetworkTransport == null) { + Unity.Netcode.Transports.UTP.UnityTransport unityTransport = new(); + nwConfig.NetworkTransport = unityTransport; + } + if (nwConfig.PlayerPrefab == null) + nwConfig.PlayerPrefab = (GameObject)Resources.Load("HumanoidPlayer"); if (playerPrefab != null) { - NetworkIdentity nwId = playerPrefab.GetComponent(); + Unity.Netcode.NetworkObject nwId = playerPrefab.GetComponent(); if (nwId == null) - nwId = playerPrefab.AddComponent(); + nwId = playerPrefab.AddComponent(); } #else if (nwManager != null) @@ -39,9 +40,7 @@ namespace Passer.Humanoid { Object.DestroyImmediate(nwId, true); } #endif -#pragma warning restore 0618 OnLoadHumanoidPlayer.UpdateHumanoidPrefab(playerPrefab, prefabPath); -#endif } } } diff --git a/Runtime/HumanoidControl/Scripts/Networking/Netcode/Editor/HumanoidNetcode_Editor.cs.meta b/Editor/HumanoidControl/Networking/Netcode/HumanoidNetcode_Editor.cs.meta similarity index 100% rename from Runtime/HumanoidControl/Scripts/Networking/Netcode/Editor/HumanoidNetcode_Editor.cs.meta rename to Editor/HumanoidControl/Networking/Netcode/HumanoidNetcode_Editor.cs.meta diff --git a/Editor/PasserVR.HumanoidControl.Editor.asmdef b/Editor/PasserVR.HumanoidControl.Editor.asmdef index 28698d3..22bccfc 100644 --- a/Editor/PasserVR.HumanoidControl.Editor.asmdef +++ b/Editor/PasserVR.HumanoidControl.Editor.asmdef @@ -1,5 +1,6 @@ { "name": "PasserVR.HumanoidControl.Editor", + "rootNamespace": "", "references": [ "PasserVR.HumanoidControl", "Passer.Visitors.Editor", @@ -8,7 +9,8 @@ "PhotonVoice.PUN", "PhotonRealtime", "PhotonVoice.API", - "SteamVR" + "SteamVR", + "Unity.Netcode.Runtime" ], "includePlatforms": [ "Editor" diff --git a/Editor/Tools/Networking/NetworkingStarter_Editor.cs b/Editor/Tools/Networking/NetworkingStarter_Editor.cs index 70ae988..c039ad2 100644 --- a/Editor/Tools/Networking/NetworkingStarter_Editor.cs +++ b/Editor/Tools/Networking/NetworkingStarter_Editor.cs @@ -17,7 +17,9 @@ namespace Passer.Humanoid { public virtual void OnEnable() { nwStarter = (NetworkingStarter)target; -#if hUNET +#if hNETCODE + OnLoadHumanoidPlayerNetcode.CheckHumanoidPlayer(); +#elif hUNET OnLoadHumanoidPlayerUnet.CheckHumanoidPlayer(); #endif #if hPHOTON1 || hPHOTON2 @@ -34,7 +36,7 @@ namespace Passer.Humanoid { public override void OnInspectorGUI() { serializedObject.Update(); -#if !hNW_UNET && !hNW_PHOTON && !hNW_MIRROR && !hNW_BOLT +#if !hNW_PHOTON && !hNETCODE EditorGUILayout.HelpBox("Networking Support is disabled. Check Preferences to enable it.", MessageType.Warning); #else @@ -57,7 +59,10 @@ namespace Passer.Humanoid { private void Inspector() { autoStartProp = serializedObject.FindProperty("autoStart"); autoStartProp.boolValue = EditorGUILayout.Toggle("Auto Start", autoStartProp.boolValue); -#if hNW_UNET +#if hNETCODE + NetworkingPrefabInspector(); + ServerTypeInspector(); +#elif hNW_UNET NetworkingPrefabInspector(); ServerTypeInspector(); #elif hNW_PHOTON @@ -82,11 +87,13 @@ namespace Passer.Humanoid { } private void ServerTypeInspector() { +#if !hNETCODE SerializedProperty serverTypeProp = serializedObject.FindProperty("serverType"); serverTypeProp.intValue = (int)(NetworkingStarter.ServerType)EditorGUILayout.EnumPopup("Server Type", (NetworkingStarter.ServerType)serverTypeProp.intValue); if ((NetworkingStarter.ServerType)serverTypeProp.intValue == NetworkingStarter.ServerType.CloudServer) CloudServerInspector(); else +#endif OwnServerInspector(); } @@ -100,6 +107,7 @@ namespace Passer.Humanoid { private void OwnServerInspector() { SerializedProperty serverIpAddressProp = serializedObject.FindProperty("serverIpAddress"); + SerializedProperty serverPortProp = serializedObject.FindProperty("serverPort"); SerializedProperty useRoleFileProp = serializedObject.FindProperty("useRoleFile"); SerializedProperty roleFileName = serializedObject.FindProperty("roleFileName"); SerializedProperty roleProp = serializedObject.FindProperty("role"); @@ -109,7 +117,7 @@ namespace Passer.Humanoid { if (useRoleFileProp.boolValue) { roleFileName.stringValue = EditorGUILayout.TextField("Role File Name", roleFileName.stringValue); EditorGUI.indentLevel++; -#if hNW_UNET || hMIRROR +#if hNETCODE || hMIRROR serverIpAddressProp.stringValue = EditorGUILayout.TextField("Server IP Address", serverIpAddressProp.stringValue); #endif EditorGUILayout.BeginHorizontal(); @@ -124,19 +132,22 @@ namespace Passer.Humanoid { } else { roleProp.intValue = (int)(NetworkingStarter.Role)EditorGUILayout.EnumPopup("Role", (NetworkingStarter.Role)roleProp.intValue); -#if hNW_UNET || hMIRROR +#if hNETCODE || hMIRROR serverIpAddressProp.stringValue = EditorGUILayout.TextField("Server IP Address", serverIpAddressProp.stringValue); #endif } } -#if hNW_UNET || hMIRROR +#if hNETCODE || hMIRROR else serverIpAddressProp.stringValue = EditorGUILayout.TextField("Server IP Address", serverIpAddressProp.stringValue); #endif #if hMIRROR - Mirror.NetworkManager nwManager = nwStarter.GetComponent(); + NetworkManager nwManager = nwStarter.GetComponent(); nwManager.networkAddress = serverIpAddressProp.stringValue; +#elif hNETCODE + serverPortProp.intValue = EditorGUILayout.IntField("Server Port", serverPortProp.intValue); #endif + } private void WriteToRoleFile(string roleFileName, string roleText, string ipAddress) { diff --git a/Runtime/HumanoidControl/Prefabs/Networking/Resources/HumanoidPlayer.prefab b/Runtime/HumanoidControl/Prefabs/Networking/Resources/HumanoidPlayer.prefab index 0c4b782..312a3ae 100644 --- a/Runtime/HumanoidControl/Prefabs/Networking/Resources/HumanoidPlayer.prefab +++ b/Runtime/HumanoidControl/Prefabs/Networking/Resources/HumanoidPlayer.prefab @@ -10,6 +10,7 @@ GameObject: m_Component: - component: {fileID: 4191195719973714} - component: {fileID: 114636771493283014} + - component: {fileID: 1251152422678924623} m_Layer: 0 m_Name: HumanoidPlayer m_TagString: Untagged @@ -27,6 +28,7 @@ Transform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 0 @@ -43,4 +45,30 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: eb69cd2012a95b549a6c414c3619432c, type: 3} m_Name: m_EditorClassIdentifier: + _syncFingerSwing: 0 + _syncFace: 0 + _syncTracking: 0 _debug: 3 + _sendRate: 25 + _createLocalRemotes: 0 +--- !u!114 &1251152422678924623 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1810220956971058} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} + m_Name: + m_EditorClassIdentifier: + GlobalObjectIdHash: 2555736071 + InScenePlacedSourceGlobalObjectIdHash: 0 + AlwaysReplicateAsRoot: 0 + SynchronizeTransform: 1 + ActiveSceneSynchronization: 0 + SceneMigrationSynchronization: 1 + SpawnWithObservers: 1 + DontDestroyWithOwner: 0 + AutoObjectParentSync: 1 diff --git a/Runtime/HumanoidControl/Scripts/Networking/Netcode/HumanoidPlayerNetcode.cs b/Runtime/HumanoidControl/Scripts/Networking/Netcode/HumanoidPlayerNetcode.cs index ad34256..1abcdfe 100644 --- a/Runtime/HumanoidControl/Scripts/Networking/Netcode/HumanoidPlayerNetcode.cs +++ b/Runtime/HumanoidControl/Scripts/Networking/Netcode/HumanoidPlayerNetcode.cs @@ -7,7 +7,7 @@ using Unity.Netcode.Components; namespace Passer.Humanoid { #pragma warning disable 0618 - [RequireComponent(typeof(NetworkObject))] + [RequireComponent(typeof(Unity.Netcode.NetworkObject))] public partial class HumanoidPlayer : NetworkBehaviour, IHumanoidNetworking { // temporary (?) dummies @@ -40,7 +40,7 @@ namespace Passer.Humanoid { // end temporary dummies public ulong nwId { - get { return identity.objectIdentity; } + get { return identity.NetworkObjectId; } } [SerializeField] @@ -55,14 +55,14 @@ namespace Passer.Humanoid { public List humanoids { get; set; } - protected NetworkObject identity; + protected Unity.Netcode.NetworkObject identity; public ulong GetObjectIdentity(GameObject obj) { - NetworkObject identity = obj.GetComponent(); + Unity.Netcode.NetworkObject identity = obj.GetComponent(); if (identity == null) return 0; - return identity.objectIdentity; + return identity.NetworkObjectId; } public GameObject GetGameObject(ulong objIdentity) { @@ -88,23 +88,23 @@ namespace Passer.Humanoid { public virtual void OnStartClient() { //name = name + " " + netId; - //NetworkManager nwManager = FindObjectOfType(); + NetworkManager nwManager = FindObjectOfType(); //short msgType = MsgType.Highest + 2; //nwManager.client.RegisterHandler(msgType, ClientProcessAvatarPose); - // No idea how this works with Netcode - //if (identity.isServer) { - // IHumanoidNetworking[] nwHumanoids = FindObjectsOfType(); - // foreach (IHumanoidNetworking nwHumanoid in nwHumanoids) { - // foreach (HumanoidControl humanoid in nwHumanoid.humanoids) { - // if (humanoid.isRemote) - // continue; + //No idea how this works with Netcode + if (IsServer) { + IHumanoidNetworking[] nwHumanoids = FindObjectsOfType(); + foreach (IHumanoidNetworking nwHumanoid in nwHumanoids) { + foreach (HumanoidControl humanoid in nwHumanoid.humanoids) { + if (humanoid.isRemote) + continue; - // DebugLog("Server Instantiate " + humanoid.nwId + " " + humanoid.humanoidId); - // ((IHumanoidNetworking)this).InstantiateHumanoid(humanoid); - // } - // } - //} + DebugLog("Server Instantiate " + humanoid.nwId + " " + humanoid.humanoidId); + ((IHumanoidNetworking)this).InstantiateHumanoid(humanoid); + } + } + } } public virtual void OnStartServer() { @@ -122,14 +122,14 @@ namespace Passer.Humanoid { humanoids = HumanoidNetworking.FindLocalHumanoids(); if (debug <= HumanoidNetworking.DebugLevel.Info) - Debug.Log((int)identity.objectIdentity + ": Found " + humanoids.Count + " Humanoids"); + Debug.Log((int)identity.NetworkObjectId + ": Found " + humanoids.Count + " Humanoids"); for (int i = 0; i < humanoids.Count; i++) { HumanoidControl humanoid = humanoids[i]; if (humanoid.isRemote) continue; - humanoid.nwId = identity.objectIdentity; + humanoid.nwId = identity.NetworkObjectId; humanoid.humanoidNetworking = this; if (debug <= HumanoidNetworking.DebugLevel.Info) @@ -173,6 +173,9 @@ namespace Passer.Humanoid { public virtual void LateUpdate() { if (Time.time > lastSend + 1 / sendRate) { + if (humanoids == null) + return; + foreach (HumanoidControl humanoid in humanoids) { if (!humanoid.isRemote) { UpdateHumanoidPose(humanoid); @@ -190,7 +193,7 @@ namespace Passer.Humanoid { override public void OnDestroy() { if (debug <= HumanoidNetworking.DebugLevel.Info) - Debug.Log((int)identity.objectIdentity + ": Destroy Remote Humanoid"); + Debug.Log((int)identity.NetworkObjectId + ": Destroy Remote Humanoid"); foreach (HumanoidControl humanoid in humanoids) { if (humanoid == null) @@ -269,7 +272,7 @@ namespace Passer.Humanoid { if (debug <= HumanoidNetworking.DebugLevel.Info) DebugLog("Received Instantiate Humanoid " + instantiateHumanoid.nwId + "/" + instantiateHumanoid.humanoidId); - if (instantiateHumanoid.nwId != identity.objectIdentity) { + if (instantiateHumanoid.nwId != identity.NetworkObjectId) { // Get the right HumanoidPlayer for this humanoid //NetworkInstanceId netId = new NetworkInstanceId((uint)instantiateHumanoid.nwId); //GameObject gameObject = ClientScene.FindLocalObject(netId); @@ -560,15 +563,15 @@ namespace Passer.Humanoid { #region Debug public void DebugLog(string message) { - Debug.Log(identity.objectIdentity + ": " + message); + Debug.Log(identity.NetworkObjectId + ": " + message); } public void DebugWarning(string message) { - Debug.LogWarning(identity.objectIdentity + ": " + message); + Debug.LogWarning(identity.NetworkObjectId + ": " + message); } public void DebugError(string message) { - Debug.LogError(identity.objectIdentity + ": " + message); + Debug.LogError(identity.NetworkObjectId + ": " + message); } #endregion diff --git a/Runtime/HumanoidControl/Scripts/Networking/Netcode/NetcodeStarter.cs b/Runtime/HumanoidControl/Scripts/Networking/Netcode/NetcodeStarter.cs index 9207373..1fbf565 100644 --- a/Runtime/HumanoidControl/Scripts/Networking/Netcode/NetcodeStarter.cs +++ b/Runtime/HumanoidControl/Scripts/Networking/Netcode/NetcodeStarter.cs @@ -1,20 +1,19 @@ -#if hNW_UNET && !UNITY_2019_1_OR_NEWER -#pragma warning disable 0618 -using System.Collections; -using System.Collections.Generic; +#if hNETCODE using UnityEngine; -using UnityEngine.Networking; -using UnityEngine.Networking.Match; +using Unity.Netcode; +using Unity.Netcode.Transports.UTP; namespace Passer { - public class UnetStarter : INetworkingStarter { + public class NetcodeStarter : INetworkingStarter { private string roomName; private int gameVersion; + public ushort serverPort; + bool matchCreated; private NetworkManager networkManager; - private NetworkMatch networkMatch; + //private NetworkMatch networkMatch; GameObject INetworkingStarter.GetHumanoidPrefab() { GameObject humanoidPrefab = Resources.Load("HumanoidPlayer"); @@ -22,42 +21,54 @@ namespace Passer { } void INetworkingStarter.StartHost(NetworkingStarter nwStarter) { - Debug.Log("start Unet Host"); + Debug.Log("start Netcode Host"); NetworkManager networkManager = nwStarter.GetComponent(); if (networkManager == null) { Debug.LogError("Could not start host: NetworkManager is missing"); return; } - networkManager.StartHost(); + //networkManager.StartHost(); + NetworkManager.Singleton.StartHost(); } void INetworkingStarter.StartClient(NetworkingStarter nwStarter) { - Debug.Log("start Unet Client"); - NetworkManager networkManager = nwStarter.GetComponent(); - NetworkClient nwClient = networkManager.StartClient(); - nwClient.Connect(nwStarter.serverIpAddress, networkManager.networkPort); + Debug.Log("start Netcode Client"); + //NetworkManager networkManager = nwStarter.GetComponent(); + //NetworkClient nwClient = + NetworkManager.Singleton.StartClient(); + NetworkManager.Singleton.GetComponent().SetConnectionData( + nwStarter.serverIpAddress, + nwStarter.serverPort + ); } - public static void StartClient(string serverIpAddress) { - Debug.Log("start Unet Client"); - NetworkManager networkManager = Object.FindObjectOfType(); - NetworkClient nwClient = networkManager.StartClient(); - nwClient.Connect(serverIpAddress, networkManager.networkPort); + public static void StartClient(string serverIpAddress, ushort serverPort) { + Debug.Log("start Netcode Client"); + //NetworkManager networkManager = Object.FindObjectOfType(); + //NetworkClient nwClient = + NetworkManager.Singleton.StartClient(); + NetworkManager.Singleton.GetComponent().SetConnectionData( + serverIpAddress, + serverPort + ); + } void INetworkingStarter.StartClient(NetworkingStarter networking, string _roomName, int _gameVersion) { roomName = _roomName; gameVersion = _gameVersion; - networkMatch = networking.gameObject.AddComponent(); - networkManager = networking.GetComponent(); + //networkMatch = networking.gameObject.AddComponent(); + //networkManager = networking.GetComponent(); - networkMatch.ListMatches(0, 10, "", true, 0, gameVersion, OnMatchList); + //networkMatch.ListMatches(0, 10, "", true, 0, gameVersion, OnMatchList); } -#region Events + public void StopClient() {; } +#region Events + /* public void OnMatchList(bool success, string extendedInfo, List matches) { if (success && matches != null) { int foundRoom = -1; @@ -108,7 +119,7 @@ namespace Passer { Debug.LogError("Join match failed " + extendedInfo); } } - + */ #endregion } } diff --git a/Runtime/PasserVR.HumanoidControl.asmdef b/Runtime/PasserVR.HumanoidControl.asmdef index d58b9c9..3e19b23 100644 --- a/Runtime/PasserVR.HumanoidControl.asmdef +++ b/Runtime/PasserVR.HumanoidControl.asmdef @@ -16,7 +16,8 @@ "SteamVR", "Unity.XR.OpenVR", "Unity.Netcode.Runtime", - "Unity.Netcode.Components" + "Unity.Netcode.Components", + "Unity.Networking.Transport" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Runtime/Tools/Networking/NetworkingStarter.cs b/Runtime/Tools/Networking/NetworkingStarter.cs index c888b65..48c727e 100644 --- a/Runtime/Tools/Networking/NetworkingStarter.cs +++ b/Runtime/Tools/Networking/NetworkingStarter.cs @@ -1,5 +1,7 @@ using System; using System.IO; +using Unity.Netcode; + #if hNW_BOLT using UdpKit; #endif @@ -26,6 +28,8 @@ namespace Passer { #endif #elif hNW_BOLT public class NetworkingStarter : Bolt.GlobalEventListener +#elif hNETCODE + public class NetworkingStarter : NetworkBehaviour #else public class NetworkingStarter : MonoBehaviour #endif @@ -33,6 +37,8 @@ namespace Passer { public bool autoStart = true; #if hNW_UNET protected INetworkingStarter starter = new UnetStarter(); +#elif hNETCODE + protected INetworkingStarter starter = new NetcodeStarter(); #elif hNW_PHOTON protected INetworkingStarter starter = new PunStarter(); #elif hNW_BOLT @@ -47,6 +53,7 @@ namespace Passer { /// The IP address of the host /// public string serverIpAddress = "127.0.0.1"; + public ushort serverPort = 1234; /// /// The name of the environment shared by all the users /// diff --git a/Samples~.meta b/Samples~.meta deleted file mode 100644 index 69b77aa..0000000 --- a/Samples~.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 86153051f48cf8c488177d8f1b7aedaa -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: