Saving non-serialized varibles editor

I have an editor script which runs a function on editor button press, and stores a bunch of variables in the edited script. Before, I was able to serialize them and save the scene, and the changes would persist even after I left the scene. But a change I made happened to make serialization impossible (I’m using a NativeArray instead of an Array.)

Now, that NativeArray is unable to be serialized, and therefore changes won’t persist through scenes. I still want the changes to be saved however.

How do I save non-serialized variables across scenes with the Editor class?

By using some data that is serializable. This may involve converting data to and form one form to another. Such as converting the NativeArray back to a regular array and back again as needed.

This works, but now I need to turn my Array back into a NativeArray to make use of IJob and Burst Compiler. What’s the easiest / fastest way to do this?

Found it, This worked for me.

NativeArray<MyStruct> myNativeArray = new NativeArray<MyStruct>(myArray, Allocator.Temp);