In general, what happens is when a button is pressed, it spawns a new gameobject with an assigned number. The new gameobject has a button, and when their button is pressed I want their assigned number to add to the total number. This works, but the number won’t add to the total until I exit playmode. (The “total number” in this case represents the total amount of money, and the gameobject’s value is represented as more money to add to the total.)
//Shared Scripts
public itemManager itm;
public MoneyManager callMoney;
public int value;
void Start () {
value = callMoney.sellValue;
}
public void childQuicksell () {
callMoney.money = callMoney.money + value; //<<<----THIS IS THE ISSUE.
callMoney.sold = true;
Debug.Log ("Sold");
}
void Update () {
}
}
I’ve used this line of code in many other scripts before and I’ve never had this issue. I’ve tried moving that line to the update function but the number just keeps adding up infinitely, again, only after I’ve exited playmode. It seems like a simple fix but I’ve been stuck on this for days. Anyone know what’s going on here?
P.S. If you don’t understand my question let me know and I’ll try my best to clarify.