Scriptable object won't save changes from my editor

My custom editor adds data to a list in my scriptable object but when i save and close unity, reopen the project all the data is lost… why is this?

In my editor code i cast target to the type and call a public method on the scriptable object like this:

//_data = target as TestObj
_data.Add(new(a,b,c, pos));
EditorUtility.SetDirty(target);

In my scriptable object i have:

//list is serialized as so:
//[SerializeField]
//List<ValueTuple<Vector3, Vector3, Vector3, Vector3>> _data = new(8);
public void Add(ValueTuple<Vector3, Vector3, Vector3, Vector3> values) => _data.Add(values);

Am i missing something? Why does it not retain the information ?

What is it a collection of?

Unity probably isn’t going to be able to serialise whatever ValueTuple is.

It’s a built in CSharp type. So we have to save the data in more basic types rather than custom types in order for it to serialize and save it?

Unity has specific rules as to what it can and can’t serialise: Unity - Manual: Script serialization

A struct from a non-Unity library likely hasn’t been set up to work with Unity. Usually they aren’t decorated with [System.Serializable] and often use auto-properties that Unity can’t serialise anyway.

You can easily just make a wrapper struct/class that does play nice with Unity for your purpose.

Ah okay ill just represent my data in a more fundamental types then combine it when needed in runtime.

Thanks

Or just do this:

Just write a struct that wraps these four Vector3s.

Also note if the editor script is a drawer for the given SO type then you should make changes only to the SerializedObject instances of the SO. Any changes made directly to the fields of the target will be lost because the editor works on a temporary instance of the target object, thus all changes need to be serialized back which is what the SerializedObject is for.