0

I'm using ScriptableObjects to store base information for tools, and trying to instantiate a unique SO for every tool in the game, so they all have unique values. The problem is that whenever a value in one clone is affected, the original SO in the inspector, and every SO in the scene is changed alongside it.

Creating unique SO (itemSetup script):

public Item baseData;
public Item Data;

public void Awake()
{
    Data = ScriptableObject.CreateInstance<Item>();
    Data = Instantiate(baseData);
}

Changing unique SO (use tool script):

gameObject.GetComponent<itemSetup>().Data.durability -= 1;
Josh
  • 1
  • 1
  • 1
    Scriptable objects tend to do that in the editor. Thats normal behavior – BugFinder Sep 22 '22 at 11:02
  • So would everything work in a proper build of the game? – Josh Sep 22 '22 at 18:20
  • Should do yes. I havent checked if the build takes the original values on the current used ones. So tbh i ended up making a reset option for what i was doing which was a quest system for rpg. Of course you should be able to tell by building and running. – BugFinder Sep 22 '22 at 18:38
  • I tried build and running and the issue persisted. Turns out instantiating in Awake() instead of Start does not work the same. – Josh Sep 22 '22 at 20:07
  • Awake maybe too early. Start should have done it. – BugFinder Sep 22 '22 at 22:27

0 Answers0