1.5M ratings
277k ratings

See, that’s what the app is perfect for.

Sounds perfect Wahhhh, I don’t wanna

Unity - Saving changes made in Play Mode!

image

Wait…that’s it?


If you’re a Unity dev, you’ve almost certainly made big, important changes to your scene before realizing that you’re in play mode and it’ll all be forgotten when you exit.

There are a few solutions out there, but they’re all geared towards saving data rather than GameObjects, which isn’t much use if you’re primarily looking to build out your scene.

Sound familiar? Well, good news! We’ve cooked up a solution called Save Play Mode Changes which you can grab here.

It works by mimicking the common trick of copy-pasting GameObjects/component data, except it’s totally automatic. All you need to do is attach a component to the root GameObject of the hierarchies you’d like saved, and it’ll retain all your changes to them! 

As you might imagine, this means you can easily end up with more being saved than you’d bargained for - instantiated objects and runtime component data - and unfortunately we don’t have a means of adding exceptions to what’s saved.

Still, we’ve been using Save Play Mode Changes for a few months now, and it’s saved us a lot of time! If you want to give it a go or help make it better, grab it now!



Ok, we’re definitely below the fold now. Want to know more, you sexy, sexy nerds? 

Ok, so how it works is: just before exiting play mode, we get all the GameObjects with our SavePlayModeChanges component, and we serialize the entire hierarchy (including components and fields) into a custom format using the dark arts of Reflection. We then use Unity’s recently added JSON serialization system to boiled that down to a nicely formatted string, which we store in EditorPrefs. When we’ve finished exiting play mode we can pull that string out, decompile it, and then reconstruct the GameObjects/etc! It’s just about as destructive as it sounds, but heck - a hack is a hack.

What’s super cool about this is that you can use the same code to serialize scene data for any other purpose - something we’ve not yet had a reason to do, but oh boy is this ripe for some serious hackery!

- Tom

unity save play mode changes inkle plugins gamedev
blog comments powered by Disqus