diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md index 9567bc8844..f56da05c9c 100644 --- a/com.unity.netcode.gameobjects/CHANGELOG.md +++ b/com.unity.netcode.gameobjects/CHANGELOG.md @@ -9,7 +9,8 @@ Additional documentation and release notes are available at [Multiplayer Documen [Unreleased] ### Added - + +- Added ability to edit the `NetworkConfig.AutoSpawnPlayerPrefabClientSide` within the inspector view. (#3097) - Added `IContactEventHandlerWithInfo` that derives from `IContactEventHandler` that can be updated per frame to provide `ContactEventHandlerInfo` information to the `RigidbodyContactEventManager` when processing collisions. (#3094) - `ContactEventHandlerInfo.ProvideNonRigidBodyContactEvents`: When set to true, non-`Rigidbody` collisions with the registered `Rigidbody` will generate contact event notifications. (#3094) - `ContactEventHandlerInfo.HasContactEventPriority`: When set to true, the `Rigidbody` will be prioritized as the instance that generates the event if the `Rigidbody` colliding does not have priority. (#3094) @@ -27,6 +28,8 @@ Additional documentation and release notes are available at [Multiplayer Documen ### Changed +- Changed `NetworkConfig.AutoSpawnPlayerPrefabClientSide` is no longer automatically set when starting `NetworkManager`. (#3097) + ## [2.0.0] - 2024-09-12 ### Added diff --git a/com.unity.netcode.gameobjects/Editor/NetworkManagerEditor.cs b/com.unity.netcode.gameobjects/Editor/NetworkManagerEditor.cs index 405291749f..0684d74849 100644 --- a/com.unity.netcode.gameobjects/Editor/NetworkManagerEditor.cs +++ b/com.unity.netcode.gameobjects/Editor/NetworkManagerEditor.cs @@ -31,6 +31,7 @@ public class NetworkManagerEditor : NetcodeEditorBase private SerializedProperty m_NetworkTransportProperty; private SerializedProperty m_TickRateProperty; #if MULTIPLAYER_SERVICES_SDK_INSTALLED + private SerializedProperty m_AutoSpawnPlayerPrefabClientSide; private SerializedProperty m_NetworkTopologyProperty; #endif private SerializedProperty m_ClientConnectionBufferTimeoutProperty; @@ -104,6 +105,11 @@ private void Initialize() m_TickRateProperty = m_NetworkConfigProperty.FindPropertyRelative("TickRate"); #if MULTIPLAYER_SERVICES_SDK_INSTALLED m_NetworkTopologyProperty = m_NetworkConfigProperty.FindPropertyRelative("NetworkTopology"); + // Only display the auto spawn property when the distributed authority network topology is selected + if (m_NetworkManager.NetworkConfig.NetworkTopology == NetworkTopologyTypes.DistributedAuthority) + { + m_AutoSpawnPlayerPrefabClientSide = m_NetworkConfigProperty.FindPropertyRelative("AutoSpawnPlayerPrefabClientSide"); + } #endif m_ClientConnectionBufferTimeoutProperty = m_NetworkConfigProperty.FindPropertyRelative("ClientConnectionBufferTimeout"); m_ConnectionApprovalProperty = m_NetworkConfigProperty.FindPropertyRelative("ConnectionApproval"); @@ -142,6 +148,11 @@ private void CheckNullProperties() m_TickRateProperty = m_NetworkConfigProperty.FindPropertyRelative("TickRate"); #if MULTIPLAYER_SERVICES_SDK_INSTALLED m_NetworkTopologyProperty = m_NetworkConfigProperty.FindPropertyRelative("NetworkTopology"); + // Only display the auto spawn property when the distributed authority network topology is selected + if (m_NetworkManager.NetworkConfig.NetworkTopology == NetworkTopologyTypes.DistributedAuthority) + { + m_AutoSpawnPlayerPrefabClientSide = m_NetworkConfigProperty.FindPropertyRelative("AutoSpawnPlayerPrefabClientSide"); + } #endif m_ClientConnectionBufferTimeoutProperty = m_NetworkConfigProperty.FindPropertyRelative("ClientConnectionBufferTimeout"); m_ConnectionApprovalProperty = m_NetworkConfigProperty.FindPropertyRelative("ConnectionApproval"); @@ -221,8 +232,17 @@ private void DisplayNetworkManagerProperties() EditorGUILayout.Space(); EditorGUILayout.LabelField("Prefab Settings", EditorStyles.boldLabel); EditorGUILayout.PropertyField(m_ForceSamePrefabsProperty); +#if MULTIPLAYER_SERVICES_SDK_INSTALLED + // Only display the auto spawn property when the distributed authority network topology is selected + if (m_NetworkManager.NetworkConfig.NetworkTopology == NetworkTopologyTypes.DistributedAuthority) + { + EditorGUILayout.PropertyField(m_AutoSpawnPlayerPrefabClientSide, new GUIContent("Auto Spawn Player Prefab")); + } +#endif EditorGUILayout.PropertyField(m_PlayerPrefabProperty, new GUIContent("Default Player Prefab")); + + if (m_NetworkManager.NetworkConfig.HasOldPrefabList()) { EditorGUILayout.HelpBox("Network Prefabs serialized in old format. Migrate to new format to edit the list.", MessageType.Info); diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs index 1cac5625e8..de08ae0ebf 100644 --- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs +++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs @@ -1161,9 +1161,6 @@ internal void Initialize(bool server) UpdateTopology(); - //DANGOEXP TODO: Remove this before finalizing the experimental release - NetworkConfig.AutoSpawnPlayerPrefabClientSide = DistributedAuthorityMode; - // Make sure the ServerShutdownState is reset when initializing if (server) { diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs index 9cd176c39b..d1582c6f03 100644 --- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs +++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs @@ -336,7 +336,7 @@ public void DeferDespawn(int tickOffset, bool destroy = true) if (!HasAuthority) { - NetworkLog.LogError($"Only the authoirty can invoke {nameof(DeferDespawn)} and local Client-{NetworkManager.LocalClientId} is not the authority of {name}!"); + NetworkLog.LogError($"Only the authority can invoke {nameof(DeferDespawn)} and local Client-{NetworkManager.LocalClientId} is not the authority of {name}!"); return; }