ScriptableObject and Editor Play Mode issue

Here’s the short version. What’s the easiest way to keep ScriptableObjects values from changing when in Play Mode in the Editor and/or reset them to their original values?

Here’s the long version. I’m using ScriptableObjects in my game for inventory items and they are working great in all aspects but one. I didn’t realize when I started using ScriptableObjects that Play Mode in the editor wouldn’t be treated the same as a compiled game. Now I cannot easily test the game in the editor without changing the default values of the items in my game. For example, if I run a test in the editor in which I purchase an item from a shop and equip it then that item’s default value will now be “equipped on character” instead of “in shop”. I suppose I could have bypassed this problem by using Monobehaviours instead of ScriptableObjects but it seems like a waste to have Transforms and such on what are essentially just data containers. Also, it would be a pain to remake all of the objects as Monobehaviours so I’d prefer not to do that. Is there an easy way to make ScriptableObjects not change their default values in the editor? I can come up with some brute force solutions to reset them but they aren’t very clean and I’m wondering if there’s a simpler solution that I don’t know about since I’m new to working with ScriptableObjects.

One simple way is to just create a fresh instance of the scriptable object before you use it:

public class Whatever : MonoBehaviour
{
    public MyInventoryThingy thing; // derived from ScriptableObject

    void Start ()
    {
        thing = Instantiate<MyInventoryThingy>(thing);
    }
}

That disconnects it from the one that is on disk however, which means once you pass that point in the code, if you pull it up in the inspector window (such as with AdvancedInspector or Odin Inspector), you will NOT be editing what’s on disk.

Thanks Kurt. Unfortunately I never actually instantiate them so I don’t think that would apply in my case. They’re just data containers. They have a bunch of fixed values (damage, stat bonuses, who can equip them, etc).

My items (which derive from ScriptableObject) also have one solitary value that changes during gameplay. That value determines where in the world that item is (ie, on character 1, on character 2, in inventory, in shop 1, etc). I need it to change in the actual game. I just don’t want changes made to it in the editor to persist.

I suppose this problem is slightly more related to the Editor and Play Mode than it is to ScriptableObjects, but they’re both part of the issue.

I wish there was an Editor setting that told Unity to treat Play Mode as an actual game and not maintain changes to ScriptableObject data but I don’t believe anything like that exists.