Hi guys,
I’ve developed a serializable action solution that handles most cases of actions, even anonymous:)
So far it only supports parameterless, single-cast actions but it is easily extendable to support other needs.
Anyway, here is my implementation:
Github Gist
Each of the scripts is a wrapper for their respective type they should serialize.
You can use the other classes if you want to add to the functionality. I commented everything to make it a bit more understandable, and expanding on the features should be quite easy.
Features:
- Supports all serializable objects of both UnityEngine.Object and System.Object
- For unserializable objects, their serializable fields get serialized, all other get defaulted (one layer only)
- Support for static methods
- Supports generic methods or methods in generic classes
- Supports even anonymous actions! You can fully use the context and reference just about all local variables!
If you find any kind of bug or constellation that does not serialize correctly, please tell me so I can fix it
SerializableAction is the backbone of UndoPro and conversely enables Undo in Node Editor Framework; here’s some more detailed explanation of what UndoPro can do and what not in regards to anonymous functions - the same applies to SerializableAction!
If I ever were to update SerializableAction, I would most likely modify UndoPro and forget about this gist, if that happens please tell me and I’ll update it.
Seneral