We still can't save changes made in play mode?

I greatly would benefit from a way to permanently save changes to a gameobject made in playmode.
I realize you can use the “Copy component” option from the gear icon – but this only works for one component at a time.

The feedback has this request with almost 900 votes.
https://feedback.unity3d.com/suggestions/editor-ability-to-save-tweaked-?page=2&_ga=2.157358650.1817538196.1516222189-1429681818.1514937348

In 2015, a Unity employee said this functionality was in development

Two solutions were removed from the asset store:

Is Unity still in the process of developing this functionality?

1 Like

It should be dropping in 2018.x as far as I remember. This is a thread that belongs in general (moved). The forums like Scripting are for actual scripting help, like how to code xyz or problem solving.

1 Like

how would this work, there are a lot of cases where i would not want to save any changes as well. like if you made a change in playmode, do you get a apply button you can hit before exiting?

1 Like

I believe that would be up to Unity to clarify when they are ready, it could well have changed since I read about it (where was that again?)

What I would like to see is the ability to serialise an entire game object hierarchy at runtime. Which would solve your issue. And it would make supporting saving and loading much simpler.

3 Likes

Have you checked the asset store? I remember seeing several options to save from play mode back into editor assets in the past.

1 Like

I see it on the roadmap under “Development”:
https://unity3d.com/unity/roadmap

Save Play Mode Changes
Make it possible to selectively persist changes made during Play Mode so they are not lost.

I would think It would have to be something that is explicitly requested on a per-gameobject basis (Just like the apply button for prefabs).

I did find one more:
https://assetstore.unity.com/packages/tools/utilities/play-mode-component-saver-104836
I’ll have to try it out and see how it works.

3 Likes

Yawn It’s 2019 and we’re STILL waiting for this feature to be added to Unity?

3 Likes

Not sure it’s very relevant any more (for me):

  • scriptable object based design survives reloading, and you will want to do that for a better project, overall
  • ECS stuff (nuff said)
  • you can right click, copy component, and after play mode, paste component values (or entire copied gameobjects if you want)

Generally just switching to scriptableobjects makes this all go away, so it’s not really a major issue plus everyone is used to using play mode now, to mess it up, then feeling relief when it’s put back in place after play mode.

So if you use ScriptableObject based data, you probably don’t even need this feature. Not saying your request is invalid, just sharing my own findings.

2 Likes

Oddly enough, saving during playtime is my biggest complaint with ScriptableObjects

1 Like

Well, technically they aren’t doing anything. They’re just not bound to the scene. To resolve this you need to keep track of the previous values, if that’s your situation as outlined here under follow up:

(but you know all that already, and I add this for future readers).

1 Like

That’s why I start with the Reset method first. All the time.

Don’t forget you can instantiate them so if it’s a chore, that’s an option…

1 Like

That’s my current approach. Any mutable ScriptableObject gets Instantiated at run time, and any changes happen to that one instead.

I’m in two minds if I ought to instantiate or not. Currently, my ScriptableObjects are designed for delegate functionality and are abstract classes, so the actor will just pick up a monobehaviour container for the SO, and it’ll tell the actor how to use it, as well as being able to construct it’s own physical representation if it needs to… solves a lot of twisted code problems but my instinct is not to give things dual purpose.

I don’t think I’ve ever been happy with a paradigm or pattern in any modern language though, so this isn’t too bad.

1 Like

Have you consider using UnityEditor.PrefabUtility.SaveAsPrefabAsset() this can save GameObject everything underneath it.

I don’t agree with that; if it was offered in future versions of Unity, it should be as a setting, not something that happens automatically.

It appears that, when I make changes in play mode, it’s always as tests; I don’t want to see those tests to be saved when I quit play mode. :slight_smile:

Our team only once needed to save changes in play mode. Of course some people would benefit from this feature, but I personally think Unity should concentrate on other areas.

We can solve this problem ourselves with better designs and in the very odd cases, where you do need to selectively save a change, you can write a small script. I can post some code, if anyone is interested, but the gist would be to simple save all fields to either json or other strings and then restoring them on enter edit mode to actually persist the changes in the editable scene. Saving can simply mean in a static variable or a temporary location to store in while exiting play mode. To tackle UnityEngine.Object references, we had success with EditorUtility.InstanceIDToObject.

Inspector Gadgets 6.0 adds a “Persist after Play Mode” feature for any modified values in the inspector.

Mildly useful at edit time. But I was after something that works at runtime.