Hide script field of netcode objects.
This commit is contained in:
parent
33a2acde25
commit
0b69c9890d
37
Runtime/DefaultNetworkBehaviourEditor.cs
Normal file
37
Runtime/DefaultNetworkBehaviourEditor.cs
Normal file
@ -0,0 +1,37 @@
|
||||
#if UNITY_EDITOR && ENABLE_NETCODE
|
||||
using Unity.Netcode;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
[CustomEditor(typeof(NetworkBehaviour), true)]
|
||||
public class DefaultNetworkBehaviourEditor : Editor
|
||||
{
|
||||
private bool hideScriptField;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
hideScriptField = target.GetType().GetCustomAttributes(typeof(HideScriptField), false).Length > 0;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (hideScriptField)
|
||||
{
|
||||
serializedObject.Update();
|
||||
EditorGUI.BeginChangeCheck();
|
||||
DrawPropertiesExcluding(serializedObject, "m_Script");
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
11
Runtime/DefaultNetworkBehaviourEditor.cs.meta
Normal file
11
Runtime/DefaultNetworkBehaviourEditor.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 759b9908922d8dc8caa70463cd752b98
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
x
Reference in New Issue
Block a user