First commit
This commit is contained in:
34
Runtime/DefaultScriptableObjectEditor.cs
Normal file
34
Runtime/DefaultScriptableObjectEditor.cs
Normal file
@ -0,0 +1,34 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Agoxandr.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
|
Reference in New Issue
Block a user