diff --git a/Assets/Mirror/Editor/NetworkBehaviourInspector.cs b/Assets/Mirror/Editor/NetworkBehaviourInspector.cs index e75a11524..1d903e0c6 100644 --- a/Assets/Mirror/Editor/NetworkBehaviourInspector.cs +++ b/Assets/Mirror/Editor/NetworkBehaviourInspector.cs @@ -17,7 +17,7 @@ public class NetworkBehaviourInspector : Editor bool syncsAnything; bool[] showSyncLists; - readonly GUIContent syncVarIndicatorContent = new GUIContent("SyncVar", "This variable has been marked with the [SyncVar] attribute."); + static readonly GUIContent syncVarIndicatorContent = new GUIContent("SyncVar", "This variable has been marked with the [SyncVar] attribute."); internal virtual bool HideScriptField => false; @@ -106,43 +106,37 @@ public override void OnInspectorGUI() while (property.NextVisible(expanded)) { bool isSyncVar = syncVarNames.Contains(property.name); - if (property.propertyType == SerializedPropertyType.ObjectReference) + + if (property.name == "m_Script") { - if (property.name == "m_Script") + if (HideScriptField) { - if (HideScriptField) - { - continue; - } - - EditorGUI.BeginDisabledGroup(true); + continue; } - EditorGUILayout.PropertyField(property, true); - - if (isSyncVar) - { - GUILayout.Label(syncVarIndicatorContent, EditorStyles.miniLabel, GUILayout.Width(EditorStyles.miniLabel.CalcSize(syncVarIndicatorContent).x)); - } - - if (property.name == "m_Script") - { - EditorGUI.EndDisabledGroup(); - } + EditorGUI.BeginDisabledGroup(true); } - else + + if (isSyncVar) { EditorGUILayout.BeginHorizontal(); + EditorGUILayout.BeginVertical(); + } - EditorGUILayout.PropertyField(property, true); - - if (isSyncVar) - { - GUILayout.Label(syncVarIndicatorContent, EditorStyles.miniLabel, GUILayout.Width(EditorStyles.miniLabel.CalcSize(syncVarIndicatorContent).x)); - } + EditorGUILayout.PropertyField(property, true); + if (isSyncVar) + { + EditorGUILayout.EndVertical(); + GUILayout.Label(syncVarIndicatorContent, EditorStyles.miniLabel, GUILayout.Width(EditorStyles.miniLabel.CalcSize(syncVarIndicatorContent).x)); EditorGUILayout.EndHorizontal(); } + + if (property.name == "m_Script") + { + EditorGUI.EndDisabledGroup(); + } + expanded = false; } serializedObject.ApplyModifiedProperties();