Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e44352d
fix: Remove "Script" fields from Netcode components in the inspector
ShadauxCat Aug 31, 2022
21a5fd6
Standards
ShadauxCat Aug 31, 2022
cf31912
standards again
ShadauxCat Aug 31, 2022
ca62e87
Fix compile errors in minimalproject
ShadauxCat Sep 7, 2022
2244781
Whoops, those version defines were for the runtime, had to add them t…
ShadauxCat Sep 7, 2022
9055ffb
Merge branch 'develop' into fix/remove_script_fields
ShadauxCat Sep 7, 2022
afcc4e0
validator...
ShadauxCat Sep 7, 2022
f57429f
Merge branch 'develop' into fix/remove_script_fields
ShadauxCat Sep 8, 2022
6926754
Merge develop into fix/remove_script_fields
netcode-ci-service Sep 8, 2022
23b2179
Merge develop into fix/remove_script_fields
netcode-ci-service Sep 8, 2022
274673d
Merge develop into fix/remove_script_fields
netcode-ci-service Sep 9, 2022
fee2b52
Merge develop into fix/remove_script_fields
netcode-ci-service Sep 12, 2022
27dd28d
Merge develop into fix/remove_script_fields
netcode-ci-service Sep 13, 2022
e74ff11
Merge develop into fix/remove_script_fields
netcode-ci-service Sep 13, 2022
c940ec8
Merge develop into fix/remove_script_fields
netcode-ci-service Sep 13, 2022
6dc626d
Merge develop into fix/remove_script_fields
netcode-ci-service Sep 14, 2022
b02493f
Merge develop into fix/remove_script_fields
netcode-ci-service Sep 14, 2022
4b9e33d
Merge develop into fix/remove_script_fields
netcode-ci-service Sep 14, 2022
d39b139
Merge develop into fix/remove_script_fields
netcode-ci-service Sep 14, 2022
2b51600
Merge develop into fix/remove_script_fields
netcode-ci-service Sep 19, 2022
14e7d1f
Fix uncaught merge conflict/compile error
ShadauxCat Sep 22, 2022
6c34462
Added some XMLDocs
ShadauxCat Sep 22, 2022
602a74a
Update package.json to 1.1.0
ShadauxCat Sep 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions com.unity.netcode.gameobjects/Editor/HiddenScriptEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using Unity.Netcode.Components;
using Unity.Netcode.Transports.UNET;
using Unity.Netcode.Transports.UTP;
using UnityEditor;

namespace Unity.Netcode.Editor
{
/// <summary>
/// Internal use. Hides the script field for the given component.
/// </summary>
public class HiddenScriptEditor : UnityEditor.Editor
Comment thread
JesseOlmer marked this conversation as resolved.
{
private static readonly string[] k_HiddenFields = { "m_Script" };
public override void OnInspectorGUI()
{
EditorGUI.BeginChangeCheck();
serializedObject.UpdateIfRequiredOrScript();
DrawPropertiesExcluding(serializedObject, k_HiddenFields);
serializedObject.ApplyModifiedProperties();
EditorGUI.EndChangeCheck();
}
}

/// <summary>
/// Internal use. Hides the script field for UNetTransport.
/// </summary>
[CustomEditor(typeof(UNetTransport), true)]
public class UNetTransportEditor : HiddenScriptEditor
{

}

/// <summary>
/// Internal use. Hides the script field for UnityTransport.
/// </summary>
[CustomEditor(typeof(UnityTransport), true)]
public class UnityTransportEditor : HiddenScriptEditor
{

}

#if COM_UNITY_MODULES_ANIMATION
/// <summary>
/// Internal use. Hides the script field for NetworkAnimator.
/// </summary>
[CustomEditor(typeof(NetworkAnimator), true)]
public class NetworkAnimatorEditor : HiddenScriptEditor
{

}
#endif

#if COM_UNITY_MODULES_PHYSICS
/// <summary>
/// Internal use. Hides the script field for NetworkRigidbody.
/// </summary>
[CustomEditor(typeof(NetworkRigidbody), true)]
public class NetworkRigidbodyEditor : HiddenScriptEditor
{

}
#endif

#if COM_UNITY_MODULES_PHYSICS2D
/// <summary>
/// Internal use. Hides the script field for NetworkRigidbody2D.
/// </summary>
[CustomEditor(typeof(NetworkRigidbody2D), true)]
public class NetworkRigidbody2DEditor : HiddenScriptEditor
{

}
#endif
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions com.unity.netcode.gameobjects/Editor/NetworkManagerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -95,7 +97,11 @@ public override void OnInspectorGUI()
}
else
{
base.OnInspectorGUI();
EditorGUI.BeginChangeCheck();
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated code... apparently one cannot add a class in between NetworkObjectEditor and Unity.Editor in the hierarchy without triggering a "public api change" error in the validator, so instead of being able to reuse this code, I have to copy/paste it...

That's pretty silly IMO.

serializedObject.UpdateIfRequiredOrScript();
DrawPropertiesExcluding(serializedObject, k_HiddenFields);
serializedObject.ApplyModifiedProperties();
EditorGUI.EndChangeCheck();

var guiEnabled = GUI.enabled;
GUI.enabled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
}
2 changes: 1 addition & 1 deletion com.unity.netcode.gameobjects/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down