I have a Usable
MonoBehaviour
, that has a list of UsageEntry
which is a Serializable
regular C# class.
[System.Serializable]
public class UsageEntry
{
[SerializeField] private string scene;
[SerializeField] private List<string> triggers = new List<string>();
public string Scene { get { return scene; } set { scene = value; } }
public List<string> Triggers { get { return triggers; } }
}
There are places in my editor code, where I make changes to the entries, mainly add/remove from the string list of triggers. I want the undo system to be able to revert those changes.
Undo.RecordObject
take a UE.Object
so I can’t pass it the entry I’m modifying.
Also, it seems that it won’t snap back if I pass it the Usable
component instead, i.e.
Undo.RecordObject(usableItem, "Updating item's trigger name");
usableItem.UpdateTriggerName(previousName, currentName);
Utils.UpdatePrefab(usableItem.gameObject);
Any ideas? (other than to make my UsageEntry
class a ScriptableObject
)
Thanks!