Question by
unity_7lKI0QYNLo5Z4w · Oct 10, 2017 at 05:33 PM ·
textunity 2d
Hi i am new to coding and know i need help.
so I've tried to make a click game and I want the text on the buttons to update so you know what they are doing and what they are costing. When I start the game, the text does not touch the buttons and I do not know why please help me for my bad English
The Script: using System.Collections; using System.Collections.Generic; using UnityEngine;
public class UppgradeManeger : MonoBehaviour {
public Click click;
public UnityEngine.UI.Text itemInfo;
public float cost;
public int count = 0;
public int clickPower;
public string itemName;
private float baseCost;
void Start()
{
baseCost = cost;
}
void Uptade () {
itemInfo.text = itemName + "\nCost: " + cost + "\nPower: +" + clickPower;
}
public void PurchasedUpgrade() {
if (click.Can >= cost) {
click.Can -= cost;
count += 1;
click.canperclick += clickPower;
cost = Mathf.Round (baseCost * Mathf.Pow(1.15f, count));
}
}
}
Comment
What is running the method "PurchasedUpgrade"? Have you set it to run from the button On Click ()?
Best Answer
Answer by FortisVenaliter · Oct 10, 2017 at 06:46 PM
It's because "Uptade" is actually spelled "Update"
I change my spelling mistake but it still doesn't update the text on the button any suggestion why