I'm making an inventory script, and I change the tags of prefabs to check if my inventory already has them stored, but when I exit the game the tags stay as stored. this is a problem because then it doesnt add or instantiate the prefab. here's the code if it helps
public void AddObjInv(GameObject InvObj, int amount)
{
if (InvObj.tag != "stored")
{
GameObject InvObj2 = Instantiate(InvObj, new Vector3(transform.position.x + 1.0f, transform.position.y, 0f), Quaternion.identity, this.transform);
if (transform.localScale.x == 1)
{
InvObj2.transform.localScale = new Vector3(-1, 1, 1);
}
InvObj2.name = InvObj.name;
InvObj2.SetActive(false);
StoredObj.Add(InvObj2);
ObjAmount.Add(amount);
InvObj.tag = "stored";
}
else
{
ObjAmount[StoredObj.IndexOf(InvObj)] += amount;
}
}
I tried OnApplicationQuit, but it wouldn't change when I stopped testing.