Instantiated ScriptableObject changes affecting original ScriptableObject values

Viewed 35

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;
0 Answers
Related