diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md index d4792c13d7..0bccbd8f86 100644 --- a/com.unity.netcode.gameobjects/CHANGELOG.md +++ b/com.unity.netcode.gameobjects/CHANGELOG.md @@ -22,6 +22,7 @@ Additional documentation and release notes are available at [Multiplayer Documen ### Fixed +- Fixed issue where a `NetworkTransform` component placed on the child of the `NetworkObject` component failed to render the inspector. (#4261) - Issue where every `NetworkObject` that started before a session logged a "Did not register because there is no session in progress!" warning when `NetworkManager.LogLevel` was `Developer`. Only `GhostObject` instances log it now. (#4245) - Fixed a NullReferenceException that would be thrown if a MonoBehaviour derived from NetworkManager defines it's own Awake or OnEnable. (#4244) - Issue where the unified bootstrap created a second world that ran a duplicate of every default system next to the default world. (#4243) diff --git a/com.unity.netcode.gameobjects/Editor/NetworkTransformEditor.cs b/com.unity.netcode.gameobjects/Editor/NetworkTransformEditor.cs index 3b61dadff2..466163b776 100644 --- a/com.unity.netcode.gameobjects/Editor/NetworkTransformEditor.cs +++ b/com.unity.netcode.gameobjects/Editor/NetworkTransformEditor.cs @@ -101,7 +101,7 @@ public override void OnEnable() private void SetGUIActive(bool active = true) { #if UNIFIED_NETCODE - if (Application.IsPlaying(m_NetworkObject) && m_NetworkObject.HasGhost) + if (m_NetworkObject != null && m_NetworkObject.HasGhost && Application.IsPlaying(m_NetworkObject)) { GUI.enabled = false; } @@ -122,8 +122,9 @@ private void DisplayNetworkTransformProperties() var networkTransform = target as NetworkTransform; #if UNIFIED_NETCODE - m_NetworkObject = networkTransform.GetComponent(); - var hasGhost = m_NetworkObject.HasGhost; + // NetworkBehaviours can be nested anywhere beneath their NetworkObject + m_NetworkObject = networkTransform.NetworkObject; + var hasGhost = m_NetworkObject != null && m_NetworkObject.HasGhost; SetGUIActive(); #else #if COM_UNITY_MODULES_PHYSICS || COM_UNITY_MODULES_PHYSICS2D @@ -333,7 +334,7 @@ private void DisplayNetworkTransformProperties() #if COM_UNITY_MODULES_PHYSICS // if rigidbody is present but network rigidbody is not present - if (hasGhost && networkTransform.TryGetComponent(out _) && networkTransform.TryGetComponent(out _) == false) + if (!hasGhost && networkTransform.TryGetComponent(out _) && networkTransform.TryGetComponent(out _) == false) { EditorGUILayout.HelpBox("This GameObject contains a Rigidbody but no NetworkRigidbody.\n " + "Add a NetworkRigidbody component to improve Rigidbody synchronization.", MessageType.Warning);