I’m working on an editor script right now and running into a serialization issue. The Monobehivor script that it edits has a serialized class in it that inherits ScriptableObject.
If I modify (via my editor script) the data in that SerializedObject, Then delete the instance of the MonoBehavior from the hierarchy and create a new instance (done via a menu static class that creates a GameObject and adds the required script/Meshfilter/Renderer etc) the data that was being serialized in that first (now deleted) instance is now associated with the newly created instance.
Any ideas why this is happening and how to prevent it?
For reference. I have combed through the answers/posts on the following pages (and many others) with much success in solving other previous issues, But Have found no answers as to why this particular problem is happening.
I fully acknowledge that I may have missed something. So if nobody has any ideas based on my description, I’ll edit this post to include the code I’m working with. Technically the class tree that I’m trying to serialize is a bit more complicated and includes a List of yet more serialized objects.
I should note, the serialization IS working the way I expect it to with the exception of this odd persistence problem.