Skip to content

Commit e7b14c2

Browse files
fix: NetworkBehaviour inspector view exceptions when using a distributed authority network topology (#3578)
This PR addresses an issue where `NetworkBehaviour` could throw an exception if viewed within the inspector view during a distributed authority network topology based session and using a DAHost that is not the authority of the associated `NetworkObject`. This PR also addresses the issue where the authority does not have editable inspector view fields when viewed by the authority during a distributed authority session. ## Changelog -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. ## Testing and Documentation - No tests have been added. - No documentation changes or additions were necessary. - Manually testing this is required to validate. <!-- Uncomment and mark items off with a * if this PR deprecates any API: ### Deprecated API - [ ] An `[Obsolete]` attribute was added along with a `(RemovedAfter yyyy-mm-dd)` entry. - [ ] An [api updater] was added. - [ ] Deprecation of the API is explained in the CHANGELOG. - [ ] The users can understand why this API was removed and what they should use instead. --> ## Backport This is a v2.x distributed authority specific issue. No back port is needed. <!-- If this is a backport: - Add the following to the PR title: "\[Backport\] ..." . - Link to the original PR. If this needs a backport - state this here If a backport is not needed please provide the reason why. If the "Backports" section is not present it will lead to a CI test failure. -->
1 parent 0e04623 commit e7b14c2

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ Additional documentation and release notes are available at [Multiplayer Documen
1010

1111
### Added
1212

13+
14+
### Fixed
15+
16+
- 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)
17+
- 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)
18+
19+
### Changed
20+
21+
22+
## [2.5.0] - 2025-08-01
23+
24+
### Added
25+
1326
- Added serializer for `Pose` (#3546)
1427
- Added methods `GetDefaultNetworkSettings` and `GetDefaultPipelineConfigurations` to `UnityTransport`. These can be used to retrieve the default settings and pipeline stages that are used by `UnityTransport`. This is useful when providing a custom driver constructor through `UnityTransport.s_DriverConstructor`, since it allows reusing or tuning the existing configuration instead of trying to recreate it. This means a transport with a custom driver can now easily benefit from most of the features of `UnityTransport`, like integration with the Network Simulator and Network Profiler from the multiplayer tools package. (#3501)
1528
- Added mappings between `ClientId` and `TransportId`. (#3516)

com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -529,11 +529,21 @@ public bool IsSessionOwner
529529

530530
internal bool IsBehaviourEditable()
531531
{
532-
// Only server can MODIFY. So allow modification if network is either not running or we are server
533-
return !m_NetworkObject ||
534-
m_NetworkObject.NetworkManager == null ||
535-
m_NetworkObject.NetworkManager.IsListening == false ||
536-
m_NetworkObject.NetworkManager.IsServer;
532+
if (!m_NetworkObject)
533+
{
534+
return true;
535+
}
536+
537+
if (!m_NetworkObject.NetworkManager)
538+
{
539+
return true;
540+
}
541+
542+
var networkManager = m_NetworkObject.NetworkManager;
543+
544+
// Only the authority can MODIFY. So allow modification if network is either not running or we are the authority.
545+
return !networkManager.IsListening ||
546+
((networkManager.DistributedAuthorityMode && m_NetworkObject.IsOwner) || (!networkManager.DistributedAuthorityMode && networkManager.IsServer));
537547
}
538548

539549
// TODO: this needs an overhaul. It's expensive, it's ja little naive in how it looks for networkObject in

0 commit comments

Comments
 (0)