Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.

Commit 08f7403

Browse files
Fixed type mismatch for persistent values in variable inspector
1 parent a617e9b commit 08f7403

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Assets/SO Architecture/Editor/Inspectors/BaseVariableEditor.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,28 @@ public override void OnInspectorGUI()
2323

2424
if (SOArchitecture_EditorUtility.HasPropertyDrawer(Target.Type))
2525
{
26-
EditorGUILayout.PropertyField(_valueProperty);
26+
//Unity doesn't like it when you have scene objects on assets,
27+
//so we do some magic to display it anyway
28+
if (typeof(Object).IsAssignableFrom(Target.Type)
29+
&& !EditorUtility.IsPersistent(_valueProperty.objectReferenceValue)
30+
&& _valueProperty.objectReferenceValue != null)
31+
{
32+
using (new EditorGUI.DisabledGroupScope(true))
33+
{
34+
EditorGUILayout.ObjectField(new GUIContent("Value"), _valueProperty.objectReferenceValue, Target.Type, false);
35+
}
36+
}
37+
else
38+
{
39+
EditorGUILayout.PropertyField(_valueProperty);
40+
}
2741
}
2842
else
2943
{
3044
EditorGUILayout.LabelField("Cannot display value. No PropertyDrawer for " + Target.Type);
3145
}
3246

33-
47+
3448
EditorGUILayout.PropertyField(_developerDescription);
3549
}
3650
}

0 commit comments

Comments
 (0)