Skip to content

Commit dfc8542

Browse files
committed
Applied changes from MissingScriptType
1 parent 31d9bdc commit dfc8542

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

Editor/Drawers/GenericUnityObjectHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void DrawMonoScript(SerializedProperty monoScriptProperty)
4949
$"Expected a MonoScript property but {monoScriptProperty.propertyPath} was passed as an argument instead.");
5050
}
5151

52-
using (new EditorGUI.DisabledScope(true))
52+
using (new EditorGUI.DisabledScope(monoScriptProperty.objectReferenceValue != null))
5353
{
5454
if (_drawForGeneric && ! (_monoScript is null))
5555
{

Editor/Drawers/UnityObjectEditor.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{
33
using System.Reflection;
44
using MissingScriptType.Editor;
5+
using SolidUtilities.Editor;
56
using UnityEditor;
67
using UnityEditor.Callbacks;
78
using UnityEngine;
@@ -64,7 +65,7 @@ void OnEnable()
6465
{
6566
_missingScriptUtility = new MissingScriptTypeUtility(serializedObject);
6667
}
67-
catch { }
68+
catch { } // SerializedObjectNotCreatableException is internal, so we can't catch it directly.
6869
#endif
6970

7071
#if EASY_BUTTONS
@@ -79,14 +80,14 @@ protected override void OnHeaderGUI()
7980

8081
public override void OnInspectorGUI()
8182
{
83+
serializedObject.UpdateIfRequiredOrScript();
84+
8285
if (target == null)
8386
{
8487
DrawMissingScript();
8588
return;
8689
}
8790

88-
serializedObject.UpdateIfRequiredOrScript();
89-
9091
#if ODIN_INSPECTOR
9192
if (target == null || GlobalConfig<GeneralDrawerConfig>.Instance.ShowMonoScriptInEditor && !target.GetType().IsDefined(typeof(HideMonoScriptAttribute), true))
9293
#endif
@@ -116,13 +117,10 @@ public override void OnInspectorGUI()
116117

117118
private void DrawMissingScript()
118119
{
119-
using (new EditorGUI.DisabledScope(true))
120-
{
121-
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Script"));
122-
}
123-
124120
#if MISSING_SCRIPT_TYPE
125-
_missingScriptUtility?.OnInspectorGUI();
121+
_missingScriptUtility?.Draw();
122+
#else
123+
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Script"));
126124
#endif
127125
}
128126
}

0 commit comments

Comments
 (0)