Simpler way to hide script field in inspector per class.
This commit is contained in:
parent
16ce496f12
commit
0e7276b98c
@ -14,6 +14,11 @@
|
||||
"name": "com.unity.modules.physics",
|
||||
"expression": "",
|
||||
"define": "COM_UNITY_MODULES_PHYSICS"
|
||||
},
|
||||
{
|
||||
"name": "com.unity.netcode.gameobjects",
|
||||
"expression": "",
|
||||
"define": "COM_UNITY_NETCODE_GAMEOBJECTS"
|
||||
}
|
||||
],
|
||||
"noEngineReferences": false
|
||||
|
@ -1,34 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
[CustomEditor(typeof(ScriptableObject), true)]
|
||||
public class DefaultScriptableObjectEditor : 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
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf2664ad6bca36847b220c7a796fda2f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,11 +1,11 @@
|
||||
#if UNITY_EDITOR
|
||||
using Unity.Netcode;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
[CustomEditor(typeof(MonoBehaviour), true)]
|
||||
public class DefaultMonoBehaviourEditor : Editor
|
||||
public abstract class HiddenScriptFieldInspector : Editor
|
||||
{
|
||||
private bool hideScriptField;
|
||||
|
||||
@ -32,5 +32,22 @@ namespace Utils
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CustomEditor(typeof(MonoBehaviour), true)]
|
||||
public class DefaultMonoBehaviourEditor : HiddenScriptFieldInspector
|
||||
{
|
||||
}
|
||||
|
||||
[CustomEditor(typeof(ScriptableObject), true)]
|
||||
public class DefaultScriptableObjectEditor : HiddenScriptFieldInspector
|
||||
{
|
||||
}
|
||||
|
||||
#if COM_UNITY_NETCODE_GAMEOBJECTS
|
||||
[CustomEditor(typeof(NetworkBehaviour), true)]
|
||||
public class DefaultNetworkBehaviourEditor : HiddenScriptFieldInspector
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb81e1373aff45646b4be5eaacc2d20f
|
||||
guid: bd71dcc30125e161ca9c7faddd531ca2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ru.shazbot.utils",
|
||||
"version": "3.1.1",
|
||||
"version": "3.1.2",
|
||||
"displayName": "Utils",
|
||||
"description": "Utility useful for almost any project.",
|
||||
"licensesUrl": "https://git.shazbot.ru/Utils.git/tree/LICENSE.md",
|
||||
|
Loading…
x
Reference in New Issue
Block a user