Hi,
I try to write my own editor.
The model for the editor looks following:
public class ThingModel : MonoBehaviour
{
[SerializeField]
public GameObject Thing;
[SerializeField]
public GameObject ThingFromScene;
}
The editor as follows:
[CustomEditor(typeof(ThingModel))]
public class ThingEditor : Editor
{
public override void OnInspectorGUI()
{
var thing = serializedObject.FindProperty("Thing");
thing.objectReferenceValue = (GameObject)EditorGUILayout.ObjectField("Thing", thing.objectReferenceValue, typeof(GameObject), false);
var thingFromScene = serializedObject.FindProperty("ThingFromScene");
thingFromScene.objectReferenceValue = (GameObject)EditorGUILayout.ObjectField("ThingFromScene", thingFromScene.objectReferenceValue, typeof(GameObject), true);
if (serializedObject.hasModifiedProperties)
serializedObject.ApplyModifiedProperties();
}
}
The property Thing works as expected and totally fine.
The property ThingFromScene works as long as no objects from scene are dropped to the field.
If so, the filed does not change its value.
The only difference is the parameter allowSceneObjects.
Any idea what I’m doing wrong or did I find a bug?
Thanky for help!