Expose UnityEvents of an instance in custom inspector

Hi guys,

I am having a bit of a problem. I am modifying a tutorial system (the Tutorial Master asset from the store) in order to adapt it to my needs. The tutorial system as a nicely made custom inspector that basically allows you to modify directly each frame of the tutorial, and I already spent 4 days on it customizing it to the needs of my game.

Now I would like to add to each frame a UnityEvent from which to call functions i want to be called at the end of each frame.

After some struggling I got to this code, but it modifies the class of the frame, and not the instance. But i can’t access with serializedObject.FindProperty (“frame_data.endOfFrameEvent”); the unityevent of the specific instant, only that of the class. Is there a way around that that you might now of?

public void DrawFrameEvents(){
        EditorGUILayout.BeginVertical("box");
        EditorGUILayout.LabelField("End of Frame events", boldText);

        SerializedProperty eventProperty = serializedObject.FindProperty ("frame_data.endOfFrameEvent");

        EditorGUILayout.PropertyField (eventProperty,true);
        serializedObject.ApplyModifiedProperties();

        GUI.enabled = true;
        EditorGUILayout.EndVertical();
    }

As I said, the above code seems to work partially, as all the frame_data classes get the same event call registered (also, it seems to be invoked for each frame of the tutorial at runtime, i get all the debug messages, but it doesn’t do anything). Also it turned all the Event inspectors (mine is the End of frame events, the second one is there for the whole tutorial) light gray, while the second one was dark gray before dunno if that means anything

2856184--208825--upload_2016-11-18_11-14-6.png

Any idea?

Cheers,
H

Add-On to the previous, the Method ClosePanel is not invoked when I call from the code (and it’s called this one for sure)

if (tutorial.tmObject.frame_data.endOfFrameEvent != null{
tutorial.tmObject.frame_data.endOfFrameEvent.Invoke ();
}