From a8b81a09786cc1ba524a7ae45e3560d70e114e65 Mon Sep 17 00:00:00 2001 From: NoelStephensUnity Date: Mon, 4 Aug 2025 10:18:33 -0500 Subject: [PATCH 1/8] fix This fixes the issue where network variables would throw an exception in distributed authority mode when viewing a NetworkBehaviour on a DAHost. --- .../Runtime/Core/NetworkBehaviour.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs index 62e60fb436..39a6893711 100644 --- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs +++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs @@ -529,11 +529,21 @@ public bool IsSessionOwner internal bool IsBehaviourEditable() { + if (!m_NetworkObject) + { + return true; + } + + if (!m_NetworkObject.NetworkManager) + { + return true; + } + + var networkManager = m_NetworkObject.NetworkManager; + // Only server can MODIFY. So allow modification if network is either not running or we are server - return !m_NetworkObject || - m_NetworkObject.NetworkManager == null || - m_NetworkObject.NetworkManager.IsListening == false || - m_NetworkObject.NetworkManager.IsServer; + return !networkManager.IsListening || + ((networkManager.DistributedAuthorityMode && m_NetworkObject.IsOwner) || (!networkManager.DistributedAuthorityMode && networkManager.IsServer)); } // TODO: this needs an overhaul. It's expensive, it's ja little naive in how it looks for networkObject in From 074f63f0c318d13154a47cffbc55709b71d220bc Mon Sep 17 00:00:00 2001 From: NoelStephensUnity Date: Mon, 4 Aug 2025 10:25:21 -0500 Subject: [PATCH 2/8] update Adding change log entry. --- com.unity.netcode.gameobjects/CHANGELOG.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md index 489af4f446..a047920159 100644 --- a/com.unity.netcode.gameobjects/CHANGELOG.md +++ b/com.unity.netcode.gameobjects/CHANGELOG.md @@ -6,7 +6,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com). -## [Unreleased] +## [Unrelease] + +### Added + + +### Fixed + +- Fixed issue where viewing a `NetworkBehaviour` with one or more `NetworkVariable` fields could throw an exception if running a distributed authority network topology with a local (DAHost) host and viewed on the host when the host is not the authority of the associated `NetworkObject`. + +### Changed + + +## [2.5.0] 2025-08-01 ### Added From 87c3c7bab133fc79703d8a8b68d66b1853e54f6b Mon Sep 17 00:00:00 2001 From: NoelStephensUnity Date: Mon, 4 Aug 2025 10:53:05 -0500 Subject: [PATCH 3/8] update Adding another change log entry. --- com.unity.netcode.gameobjects/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md index a047920159..3968ba8964 100644 --- a/com.unity.netcode.gameobjects/CHANGELOG.md +++ b/com.unity.netcode.gameobjects/CHANGELOG.md @@ -14,6 +14,7 @@ Additional documentation and release notes are available at [Multiplayer Documen ### Fixed - Fixed issue where viewing a `NetworkBehaviour` with one or more `NetworkVariable` fields could throw an exception if running a distributed authority network topology with a local (DAHost) host and viewed on the host when the host is not the authority of the associated `NetworkObject`. +- Fixed issue when using a distributed authority network topology and viewing a `NetworkBehaviour` with one or more `NetworkVariable` fields in the inspector view would not show editable fields. ### Changed From 58cb751fedbdd6c0e5fb847f550a742aa30bf041 Mon Sep 17 00:00:00 2001 From: NoelStephensUnity Date: Mon, 4 Aug 2025 10:54:10 -0500 Subject: [PATCH 4/8] update Adding the associated PR number to the changelog entries. --- com.unity.netcode.gameobjects/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md index 3968ba8964..d788c42c58 100644 --- a/com.unity.netcode.gameobjects/CHANGELOG.md +++ b/com.unity.netcode.gameobjects/CHANGELOG.md @@ -13,8 +13,8 @@ Additional documentation and release notes are available at [Multiplayer Documen ### Fixed -- Fixed issue where viewing a `NetworkBehaviour` with one or more `NetworkVariable` fields could throw an exception if running a distributed authority network topology with a local (DAHost) host and viewed on the host when the host is not the authority of the associated `NetworkObject`. -- Fixed issue when using a distributed authority network topology and viewing a `NetworkBehaviour` with one or more `NetworkVariable` fields in the inspector view would not show editable fields. +- Fixed issue where viewing a `NetworkBehaviour` with one or more `NetworkVariable` fields could throw an exception if running a distributed authority network topology with a local (DAHost) host and viewed on the host when the host is not the authority of the associated `NetworkObject`. (#3578) +- Fixed issue when using a distributed authority network topology and viewing a `NetworkBehaviour` with one or more `NetworkVariable` fields in the inspector view would not show editable fields. (#3578) ### Changed From 387c10b795aec4eb283f28ffcdeec8e3cca67419 Mon Sep 17 00:00:00 2001 From: NoelStephensUnity Date: Mon, 4 Aug 2025 11:11:09 -0500 Subject: [PATCH 5/8] update Fixing spelling issue with Unreleased section. --- com.unity.netcode.gameobjects/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md index d788c42c58..1adea77435 100644 --- a/com.unity.netcode.gameobjects/CHANGELOG.md +++ b/com.unity.netcode.gameobjects/CHANGELOG.md @@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com). -## [Unrelease] +## [Unreleased] ### Added From 67ca74985a99299865b88e2777d60ffcad1dd03e Mon Sep 17 00:00:00 2001 From: NoelStephensUnity Date: Mon, 4 Aug 2025 11:40:18 -0500 Subject: [PATCH 6/8] update Adding missing '-'. --- com.unity.netcode.gameobjects/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md index 1adea77435..db93801f9a 100644 --- a/com.unity.netcode.gameobjects/CHANGELOG.md +++ b/com.unity.netcode.gameobjects/CHANGELOG.md @@ -19,7 +19,7 @@ Additional documentation and release notes are available at [Multiplayer Documen ### Changed -## [2.5.0] 2025-08-01 +## [2.5.0] - 2025-08-01 ### Added From a6589319cdb474878b4a4c67654bd32a43469a29 Mon Sep 17 00:00:00 2001 From: NoelStephensUnity Date: Mon, 4 Aug 2025 11:42:17 -0500 Subject: [PATCH 7/8] style Updating comment to better reflect the change. --- com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs index 39a6893711..2bab808b48 100644 --- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs +++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs @@ -541,7 +541,7 @@ internal bool IsBehaviourEditable() var networkManager = m_NetworkObject.NetworkManager; - // Only server can MODIFY. So allow modification if network is either not running or we are server + // Only the authority can MODIFY. So allow modification if network is either not running or we are the authority. return !networkManager.IsListening || ((networkManager.DistributedAuthorityMode && m_NetworkObject.IsOwner) || (!networkManager.DistributedAuthorityMode && networkManager.IsServer)); } From a0987360b7dbae4d73192525d2714dbffa2b6dd5 Mon Sep 17 00:00:00 2001 From: NoelStephensUnity Date: Mon, 4 Aug 2025 13:20:48 -0500 Subject: [PATCH 8/8] style Removing white spaces. --- com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs index 2bab808b48..f871b79331 100644 --- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs +++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs @@ -542,7 +542,7 @@ internal bool IsBehaviourEditable() var networkManager = m_NetworkObject.NetworkManager; // Only the authority can MODIFY. So allow modification if network is either not running or we are the authority. - return !networkManager.IsListening || + return !networkManager.IsListening || ((networkManager.DistributedAuthorityMode && m_NetworkObject.IsOwner) || (!networkManager.DistributedAuthorityMode && networkManager.IsServer)); }