- Home /
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:
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 am looking for this as well. in trying to use SerializedProperty, I always get null
I'm glad its not just me then! Still no progress on this from me unfortunately :(
@$$anonymous$$2 Games. I got it working in the end, added the link as an answer
Answer by mikrima · Dec 10, 2015 at 05:25 PM
I had the same issue - the parameter values would always disappear. Here is what worked for me in the end:
Call "serializedObject.Update();" in the beginning of OnInspectorGUI
Call "serializedObject.ApplyModifiedProperties();" at the end of OnInspectorGUI
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)
Answer by Jean-Fabre · Jul 21, 2015 at 05:51 AM
Hi,
That worked for me: http://answers.unity3d.com/questions/802786/46-how-do-i-draw-unityevent-in-custom-inspector.html
Bye,
Jean
Your answer
![](https://koobas.hobune.stream/wayback/20220613195918im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
UnityEvent Serialization Problem 1 Answer
Unity Editor Scripts: GameObject Added / Removed Event? 1 Answer
Non-monobehavior editor script subscribing to delegate event and persisting on application reload 0 Answers
Event.current.Use() not consuming event in editor SceneView 1 Answer
Is there a way to implement mouse events in the game view in edit mode? 1 Answer