Question by
BusaniX · Oct 22, 2019 at 10:01 AM ·
scriptableobjectcustom editorcustom-inspectorguilayouteditorguilayout
EditorGUILayout.ObjectField on a ScriptableObject's inspector doesn't update properly
Hello,
This is my first time trying out custom editors, I'm trying to make one for my scriptable object called ItemData. At one point in the ItemDataEditor, the script for the custom editor, I try to use EditorGUILayout.ObjectField() to get a prefab for a mesh object, using the following code:
.
public override void OnInspectorGUI()
{
(...)
GameObject b = null;
GUILayout.BeginHorizontal();
GUILayout.Label("Mesh Prefab", GUILayout.Width(labelWidth));
b = (GameObject) EditorGUILayout.ObjectField(b, typeof(GameObject), false);
// data is the target object
data.meshPrefab = b == null ? null : b.transform;
GUILayout.EndHorizontal();
}
.
It all works fine but when I drag a prefab to the field on the inspector it doesn't update, it just stays null as if I didn't assign anything. Any help? Thanks!
Comment