Please help…this is a pain in the a…
My scene have 2 buttons, each target to increase the variable day by 1, and money by -100/-1000;
but it comes out that when I click button 1 three times, day becomes 2,3,4, that’s correct
but when I click button 2, day becom 2 again… and then 3,4,5…
it seems that each button have their own value for variable day and money…
but I didn’t assign two variables…I just assigned one, please help…
<
int gDayLeft;
public Text gDay;
public Button button1;
int gbudget;
public Text gBudgetText;
// Use this for initialization
void Start () {
gDayLeft = 365;
gDay.text = “尚餘 " + gDayLeft.ToString () + " 天”;
gbudget = 1000000;
gBudgetText.text = "$ " + gbudget;
}
public void clickButtonDL()
{ gDayLeft–;
gDay.text = “尚餘 " + gDayLeft.ToString () +” 天";
gbudget = gbudget - 10000;
gBudgetText.text = "$ " + gbudget;
print (gbudget);
}
public void clickButtonAdv()
{ gDayLeft–;
gDay.text = “尚餘 " + gDayLeft.ToString () +” 天";
gbudget = gbudget - 50000;
gBudgetText.text = "$ " + gbudget;
print (gbudget);
}
// Update is called once per frame
void Update () {
gDayLeft = gDayLeft;
gbudget = gbudget;
}
}