Get the name of a property within a property in SerializedObject.FindProperty

What I have is a serialized class that has a UnityEvent within it. What I want to do is get that UnityEvent using the SerializedObject.FindProperty method. Unfortunately, I’m not quite sure of how to format the string in order to get to it.

Here is the snippet that I need help figuring out:

public class RPGEventPage
{
    public List<RPGEventCommand> commands;
}

public class RPGEventCommand
{
    public UnityEvent command;
}
RPGEventCommand rpgEventCommand = eventPage.commands [i];
SerializedProperty commandEvent = serializedObject.FindProperty ("this is where the string goes");
EditorGUILayout.PropertyField (commandEvent);

First of all this thread is more suitable to the Extensions & OnGUI forum.

Having said that, this looks odd. It could be just because this is a snippet, but what i’m seeing is a call to serializedObject.FindProperty. In this case, I would ask what is the serializedObject ? in an editor script, it will be the top level object being edited. Assuming the editor is for RPGEventPage class, this is how you can access it:

//holds the List property
SerializedProperty commandsProperty = serializedObject.FindProperty("commands");
//holds the RPGEventCommand instance inside the array at index i
SerializedProperty RPGEventCommandClass = commandsProperty.GetArrayElementAtIndex(i);
//Holds the command property within the RPGEventCommand class
SerializedProperty UnityEventCommandProperty = RPGEventCommandClass.FindPropertyRelative("command");

This is exactly what I needed! Just to correct myself, I forget to mention that the top level object was an RPGEvent Class, so I just used the method you gave me to work my way down to the UnityEvent command. Thanks.