Problems with saving data on GameObject using custom EditorWindow

I’m creating my RPG game and I’m just stuck with data saving problem.

I’ve got a class named Attribute with some private fields in it (such as it’s ID, name and value) to expose some attributes of character such as Agility, Strength etc.
It is marked as [Serializable]. And also it’s private fields are marked with [SerializeField].

Class Attribute has a field Value which is type of class BasedValue that has protected float fields (they also marked as [SerializeField]): min, max and base.

Also, I’ve created a class CreatureLifeStatus (it extends MonoBehaviour) which has a field - List<Attribute>. And this field marked with [SerializeField].

The next class is CharacterEditor which is used for editing any character on scene. It extends EditorWindow. The first feature I’ve implemented for it - a simple editor of CreatureLifeStatus:

It takes an object from ObjectField with label “Character object”, as you can see. Then, it takes a reference to CreatureLifeStatus instance on that object. And, the last step, is getting all attributes from the list in it and editing them.

//CreatureLifeStatus has an indexer to get attributes by ID
BasedValue attributeValue = lifeStatus[id].Value; 
attributeValue.MinValue = EditorGUILayout.FloatField("Min value:", attributeValue.MinValue);
attributeValue.BaseValue = EditorGUILayout.FloatField("Base value:", attributeValue.BaseValue);
attributeValue.MaxValue = EditorGUILayout.FloatField("Max value:", attributeValue.MaxValue);        

So, it’s simply changes values in this instance.

The problem is: when I change values, using my custom editor window, I can see those changes on my object in automatically created editor:

But. When (after doing some changes in my custom editor window) I enter the Play mode, all changes are discarded.
Otherwise, after using automatically created editor (on previous screenshot), changes will be saved.

I’m not sure I’m clearely expressed my problem - I’m asking for help here for the first time, but if any question appeares, please let me know :slight_smile:

Well, to solve this problem I’ve desided to rebuild the whole system. And while rebuilding it, I’ve found the solution for my problem:
before doing some changes to my object in EditorWindow, I should write this code:

Undo.RecordObject(lifeStatus, string.Empty);

And after doing some changes:

if (EditorGUI.EndChangeCheck())

It works just as I need: all the changes I’ve made to my object are getting saved, and won’t reset after entering PlayMode or after reloading Editor.