Custom Inspector: Unity Events

Hey everyone, I am having trouble today with a custom inspector that handles UnityEvent’s.
Whats happening is that if I make a custom inspector for a UnityEvent then I can set all the data fine but if I select a new object then the data for the input of the method is lost.

So:

46604-forum.png

This is the result after selecting another object and returning. As you can see which method to run and which object to send the message to is retained but any input data is always lost. This even applies for simple methods such as gameobject.SetActive so it effects primitive data as well as objects.

Anyone any ideas if I am doing anything wrong or is this a bug?

(To recreate create a custom inspector and display an event using a property field)

Cheers!
Jason

I had the same issue - the parameter values would always disappear.
Here is what worked for me in the end:

  1. Call “serializedObject.Update();” in the beginning of OnInspectorGUI
  2. Call “serializedObject.ApplyModifiedProperties();” at the end of OnInspectorGUI
  3. Either DON’T draw the default inspector, or draw it AFTER the call to ApplyModifiedProperties (otherwise your value will jump right back to what it was before)

Hi,

That worked for me: [4.6] How do i draw UnityEvent in Custom Inspector - Unity Answers

Bye,

Jean