Objectfield change event

Hi, i’m working in a custom editor window.
I need an object field to define a graph for my system, but the problem is neither i know how to retrieve the current object in the Object field or register change events on the object field.

I’ve tried both

ObjectField.RegisterValueChangedCallback

and

ObjectField.RegisterCallback<ChangeEvent<CustomGraph>>

They don’t call any change when switching objectfield element.

I though about using binding, but its a bit weird because id need to create a serialized object just for saving the custom graph element.

Is there any way to know change events on object field or retrieve the object?
Thanks.

Sorry, it was my own mistake, i wasn’t actually checking correctly.
The one which works in this case is:

ObjectField.RegisterValueChangedCallback

If any mods sees this thread it can be deleted. I don’t know if i can do it.

1 Like

Remember that you need to be using both UnityEditor.UIElements and UnityEngine.UIElements since ObjectField is in the UinityEditor.UIElemnets namespace but RegisterValueChangedCallback and the CangeEvent are both in the UnityEngine.UIElements namespace which is inconvenient

1 Like