Question by
ZachAttack9280 · Oct 12, 2015 at 11:25 PM ·
rotationaddmoneymoneysystem
Money not being added.
Ok so i have a code already that does this: when the loading bar is finished, i can click this button the loading bar resets and gives me the x amount of money, i made another with a new code except copy and pasted and all. here is the first one.
Code:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class TreeCutters : MonoBehaviour {
public UnityEngine.UI.Text moneyEarned;
public UnityEngine.UI.Text moneyDisplay;
public Transform LoadingBar;
public Transform TextIndicator;
public Transform TextLoading;
[SerializeField] private float currentAmount;
[SerializeField] private float speed;
public float money = 0f;
public int moneyperclick = 1;
void Update () {
moneyDisplay.text = "$" + money;
moneyEarned.text = "$" + moneyperclick * 2;
if (currentAmount < 100) {
currentAmount += speed * Time.deltaTime;
TextIndicator.GetComponent<Text> ().text = ((int)currentAmount).ToString () + "%";
TextLoading.gameObject.SetActive (true);
} else {
TextLoading.gameObject.SetActive (false);
TextIndicator.GetComponent<Text> ().text = "Ready!";
}
LoadingBar.GetComponent<Image> ().fillAmount = currentAmount / 100;
}
public void clicked() {
if (currentAmount > 99) {
money += moneyperclick;
money = money + moneyperclick;
currentAmount = 0;
}
}
}
error: none but i do get the money added to the moneyDisplay.text
This is the second one that doesn't work.
code:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class ExtremeBuilders : MonoBehaviour {
public UnityEngine.UI.Text moneyEarned2;
public UnityEngine.UI.Text moneyDisplay;
public Transform LoadingBar;
public Transform TextIndicator;
public Transform TextLoading;
[SerializeField] private float currentAmount;
[SerializeField] private float speed;
public float money = 0f;
public int moneyperclick = 5;
void Update () {
moneyDisplay.text = "$" + money;
moneyEarned2.text = "$" + moneyperclick * 2;
if (currentAmount < 100) {
currentAmount += speed * Time.deltaTime;
TextIndicator.GetComponent<Text> ().text = ((int)currentAmount).ToString () + "%";
TextLoading.gameObject.SetActive (true);
} else {
TextLoading.gameObject.SetActive (false);
TextIndicator.GetComponent<Text> ().text = "Ready!";
}
LoadingBar.GetComponent<Image> ().fillAmount = currentAmount / 100;
}
public void clicked() {
if (currentAmount > 99) {
money += moneyperclick;
money = money + moneyperclick;
currentAmount = 0;
}
}
}
error: none but i dont get money added to moneyDisplay.text
I dont understand what the problem is. DO you know?
Comment