I'm making a node editor in Unity using an EditorWindow, I'm currently trying to make it so designers can add their own methods to a node using serialized UnityEvents; but I haven't been able to get it to function properly.
SerializedObject serializedObject = new SerializedObject(selectedNode.NodeState);
SerializedProperty property = serializedObject.GetIterator();
property.Next(true);
while (property.NextVisible(false))
{
EditorGUILayout.PropertyField(property);
}
serializedObject.ApplyModifiedProperties();
serializedObject.Update();
The above code runs through through all necessary fields of the class so the user can modify them.
Everything functions perfectly with the exception of UnityEvents. They almost do as I intend them to do, except they don't preserve the variable inputs of inserted object's method. If I keep working within the editor window they stay, but if I close the window and re-open the inputted variable resets.
I thought this may be caused by an issue somewhere else in my code, but all other fields work fine.