diff --git a/com.unity.netcode.gameobjects/Editor/HiddenScriptEditor.cs b/com.unity.netcode.gameobjects/Editor/HiddenScriptEditor.cs new file mode 100644 index 0000000000..58000fd503 --- /dev/null +++ b/com.unity.netcode.gameobjects/Editor/HiddenScriptEditor.cs @@ -0,0 +1,74 @@ +using Unity.Netcode.Components; +using Unity.Netcode.Transports.UNET; +using Unity.Netcode.Transports.UTP; +using UnityEditor; + +namespace Unity.Netcode.Editor +{ + /// + /// Internal use. Hides the script field for the given component. + /// + public class HiddenScriptEditor : UnityEditor.Editor + { + private static readonly string[] k_HiddenFields = { "m_Script" }; + public override void OnInspectorGUI() + { + EditorGUI.BeginChangeCheck(); + serializedObject.UpdateIfRequiredOrScript(); + DrawPropertiesExcluding(serializedObject, k_HiddenFields); + serializedObject.ApplyModifiedProperties(); + EditorGUI.EndChangeCheck(); + } + } + + /// + /// Internal use. Hides the script field for UNetTransport. + /// + [CustomEditor(typeof(UNetTransport), true)] + public class UNetTransportEditor : HiddenScriptEditor + { + + } + + /// + /// Internal use. Hides the script field for UnityTransport. + /// + [CustomEditor(typeof(UnityTransport), true)] + public class UnityTransportEditor : HiddenScriptEditor + { + + } + +#if COM_UNITY_MODULES_ANIMATION + /// + /// Internal use. Hides the script field for NetworkAnimator. + /// + [CustomEditor(typeof(NetworkAnimator), true)] + public class NetworkAnimatorEditor : HiddenScriptEditor + { + + } +#endif + +#if COM_UNITY_MODULES_PHYSICS + /// + /// Internal use. Hides the script field for NetworkRigidbody. + /// + [CustomEditor(typeof(NetworkRigidbody), true)] + public class NetworkRigidbodyEditor : HiddenScriptEditor + { + + } +#endif + +#if COM_UNITY_MODULES_PHYSICS2D + /// + /// Internal use. Hides the script field for NetworkRigidbody2D. + /// + [CustomEditor(typeof(NetworkRigidbody2D), true)] + public class NetworkRigidbody2DEditor : HiddenScriptEditor + { + + } +#endif +} diff --git a/com.unity.netcode.gameobjects/Editor/HiddenScriptEditor.cs.meta b/com.unity.netcode.gameobjects/Editor/HiddenScriptEditor.cs.meta new file mode 100644 index 0000000000..f8dd8da119 --- /dev/null +++ b/com.unity.netcode.gameobjects/Editor/HiddenScriptEditor.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ebf622cc80e94f488e59caf8b7419f50 +timeCreated: 1661959406 \ No newline at end of file diff --git a/com.unity.netcode.gameobjects/Editor/NetworkManagerEditor.cs b/com.unity.netcode.gameobjects/Editor/NetworkManagerEditor.cs index a788cb8f3e..debaca2e45 100644 --- a/com.unity.netcode.gameobjects/Editor/NetworkManagerEditor.cs +++ b/com.unity.netcode.gameobjects/Editor/NetworkManagerEditor.cs @@ -214,18 +214,6 @@ public override void OnInspectorGUI() DrawInstallMultiplayerToolsTip(); #endif - { - var iterator = serializedObject.GetIterator(); - - for (bool enterChildren = true; iterator.NextVisible(enterChildren); enterChildren = false) - { - using (new EditorGUI.DisabledScope("m_Script" == iterator.propertyPath)) - { - EditorGUILayout.PropertyField(iterator, false); - } - } - } - if (!m_NetworkManager.IsServer && !m_NetworkManager.IsClient) { serializedObject.Update(); diff --git a/com.unity.netcode.gameobjects/Editor/NetworkObjectEditor.cs b/com.unity.netcode.gameobjects/Editor/NetworkObjectEditor.cs index 5111e92fcc..c63f9fc10e 100644 --- a/com.unity.netcode.gameobjects/Editor/NetworkObjectEditor.cs +++ b/com.unity.netcode.gameobjects/Editor/NetworkObjectEditor.cs @@ -15,6 +15,8 @@ public class NetworkObjectEditor : UnityEditor.Editor private NetworkObject m_NetworkObject; private bool m_ShowObservers; + private static readonly string[] k_HiddenFields = { "m_Script" }; + private void Initialize() { if (m_Initialized) @@ -95,7 +97,11 @@ public override void OnInspectorGUI() } else { - base.OnInspectorGUI(); + EditorGUI.BeginChangeCheck(); + serializedObject.UpdateIfRequiredOrScript(); + DrawPropertiesExcluding(serializedObject, k_HiddenFields); + serializedObject.ApplyModifiedProperties(); + EditorGUI.EndChangeCheck(); var guiEnabled = GUI.enabled; GUI.enabled = false; diff --git a/com.unity.netcode.gameobjects/Editor/com.unity.netcode.editor.asmdef b/com.unity.netcode.gameobjects/Editor/com.unity.netcode.editor.asmdef index ab1d2717e4..0648dd9341 100644 --- a/com.unity.netcode.gameobjects/Editor/com.unity.netcode.editor.asmdef +++ b/com.unity.netcode.gameobjects/Editor/com.unity.netcode.editor.asmdef @@ -13,6 +13,21 @@ "name": "com.unity.multiplayer.tools", "expression": "", "define": "MULTIPLAYER_TOOLS" + }, + { + "name": "com.unity.modules.animation", + "expression": "", + "define": "COM_UNITY_MODULES_ANIMATION" + }, + { + "name": "com.unity.modules.physics", + "expression": "", + "define": "COM_UNITY_MODULES_PHYSICS" + }, + { + "name": "com.unity.modules.physics2d", + "expression": "", + "define": "COM_UNITY_MODULES_PHYSICS2D" } ] -} \ No newline at end of file +} diff --git a/com.unity.netcode.gameobjects/package.json b/com.unity.netcode.gameobjects/package.json index 641a768117..75c3b561cb 100644 --- a/com.unity.netcode.gameobjects/package.json +++ b/com.unity.netcode.gameobjects/package.json @@ -2,7 +2,7 @@ "name": "com.unity.netcode.gameobjects", "displayName": "Netcode for GameObjects", "description": "Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.", - "version": "1.0.1", + "version": "1.1.0", "unity": "2020.3", "dependencies": { "com.unity.nuget.mono-cecil": "1.10.1",