#Wdym by format
1 messages · Page 1 of 1 (latest)
For example, the prefabs currently have 3 List<Vector3>s, and I'm planning to switch it to List<class>, where the objects are a triple of Vector3s. And, if I just make that change in my object, the data will be lost in my prefabs
Unity has no builtin support for migrations of that nature besides the serialization callbacks or additive format changes and custom implementations of these migrations based on the old/new fields.
I would also highly recommend using an actual struct or class type instead of object
Funny you say that, because in this thread, somebody suggested the opposite
~~https://discord.com/channels/489222168727519232/1288191417776083005~~
oh wait
sorry, I was conflating object and class
@dawn wolf great, I got it working with ISerializationCallbackReceiver, thanks!
Out of my own curiosity - could I not achieve this with any sort of one-shot scripting? I did get the desired effect by modifying my class and forcing an OnBeforeSerialize, but:
- it feels odd to implement this method, given that I'll be deleting the implementation after the migration
- I'll have to figure out how to trigger an
OnBeforeSerializefor all of my prefabs - I see that prefabs have human-readable serialization, so it seems like it would be simple enough to provide some sort of interface for modifying the prefab files
Though I get that this is an odd use-case, and it's not that hard to write but it's also probably not super in-demand
@dawn wolf it ended up being the case that the OnBeforeSerialize step didn't necessarily write the serializations to Disk, so I had to get it to do so with this strategy
You still need to save the asset database