Play Mode Save

This tool allows you to save changes made in play mode.

Features

  • Save changes made in play mode to any component, built-in or custom.
  • Save a snapshot of the values of the component.
  • Save the values of the component as they are when exiting play mode.
  • Save the values of SriptableObjects immediately.
  • Auto-Save.
  • Save all components in a game object and its children.
  • Save objects created in play mode.
  • New features are continuously added based on user requests.

Limitations

  • Only works on Unity 2019.2 or higher.

How to use:

  1. In play mode. Right-click on the component to open the context menu.
  2. Click Save Now or Save When Exiting Play Mode.

Links:
Asset Store
Documentation

Please post any feedback, suggestions or ask for support or missing features here.

6 Likes

Nice extension!

I think adding a checkbox as well for auto-saving (only on edit of course) would make it even more useful.

1 Like

Hey thanks for the suggestion, it had occurred to me too, but the thing is, making the data in edit mode persist in play mode is a bit tricky. But your suggestion encouraged me to find a solution and I already came up with a trick to make it work.

2 Likes

Very useful! However, the auto-saver is not working for me. What could it be?

Also, can I apply changes made from code as well once the auto-saver works again? I’ve been trying to get the auto-saver to work myself but I don’t know how to keep track of the changed objects in the editor script once play mode exits.

EDIT: Actually never mind. This one worked Persistent Components | Utilities Tools | Unity Asset Store. Thanks anyway!

Hey, at the moment PlayModeSave is not designed to work as you think. Right now, the tool allows you to take a snapshot of a transform and save it when exiting play mode. No matter how you modify the transform after saving it, it only keeps the values you saved before and applies them when you exit play mode. However, I think I’ll add the option to save the transform values as they are just before exiting play mode, or in other words make the transforms persistent.

BTW, the tool you mention looks great and allows you to make other components persistent not just transforms. But if what you need is to take a snapshot, you can use PlayModeSave.

1 Like

Thank you for your reply!

Got it! I would love it if you could make the transform values persistent in such a way that I could run the program, make the changes I want through code alone, then simply exit play mode. The other tool seems amazing but it actually caused some problems with other things that should not have been affected.

If you make these changes in the next couple of days please do let me know because it would be very useful to me!

Hey, version 2.0 is available and now you can save changes made in play mode to any component, built-in or custom. You can also save component values as they are when exiting play mode (that is, persistent components until exiting play mode). Check it out.

1 Like

Awesome, thanks!

Hi there! Thanks for your asst.
Is it possible to use your asset to save ScriptableObject changes in Play Mode (i.e. “Save Now”) ?
If not, would it be hard to add such feature? Would really appreciate it

Hey, I’m sorry, but I think I’m not understanding what you want to do. ScriptableObjects are assets, so they are persistent between sessions and do not need to be saved. Play Mode Save only saves changes to serializable components, that is, all built-in components and custom components with serialized fields. However, the tool has a limitation: It does not save changes to objects and components created in play mode. Is this limitation related with you want to do?
Could you please explain your case more specifically in order to understand what you want to do.

I have a class which is derived from ScriptableObject and an asset of such type.
During the play mode I’m able to modify its fields and later, upon exiting the play mode its contents are being serialized by Unity and saved to the corresponding asset.

However if Unity crashes or hangs because of some problem (that can happen for example after even a small change to a C# script), its contents are not being saved, and all my work is lost.
Thus, it would be awesome to be able to “Save now” such an asset during the play mode or (that one is optional) configure an auto-save (with some period of time or after each change).

I think the code can be found here: Saving SerializedObject assets in play mode? : Unity3D (reddit.com)

AssetDatabase.Refresh();
EditorUtility.SetDirty(level);
AssetDatabase.SaveAssets();

However I’m not sure how to use it in a proper way in such scenario, and maybe it would be useful to include it to your asset for the sake of completeness

Hey. Now I understand what you want to do. Ok, I will add that functionality to the tool in the next version. In the meantime, check if this works:

[MenuItem("CONTEXT/ScriptableObject/Save Now", false, 2000)]
        private static void SaveScriptableObject(MenuCommand command)
        {
            AssetDatabase.Refresh();
            EditorUtility.SetDirty(command.context);
            AssetDatabase.SaveAssets();
        }
1 Like

Version 2.1 is now available. Now you can save ScriptableObjects.

1 Like

Ok, I can confirm it’s working now! So nice!

Btw just wondering whether you have any plans on implementing some of these features:

  • auto-save with some period of time (optionally enabled) - can save work in case of crashes and if you forgot to “Save now”
  • a custom “Save” button (which may change the color depending on whether any changes were made since the last save)

    that way it’s easier to remember that you might need to save the changes

Thank you!!!

Glad to hear that the new feature is working.
About the new features you mention, I’ll keep them in mind for future versions.
Thanks for helping me improving the tool.

1 Like

Hey this is cool! I am trying to change sorting layers on a sprite renderer and unfortunately the changes don’t get saved.

You’re right, unfortunately it seems like that property doesn’t have a serializable backing field. But I can fix it. It will be available in the next version.

Awesome thanks! Ya I would love to use your asset as it seems immensely helpful, but hopefully you can understand that if I’m not sure which aspects of components will or will not be saved, then that uncertainty renders it to a large extent unusable. Looking forward to trying the next version though and will be following the progress! Cheers.

Sorry for the double post… I realize I spoke a bit in hyperbole there. It’s not that big of a deal to keep a closer eye on what’s being saved, and I just wanted to say that the speed of that update today was awesome. Appreciate it!