It changes the text, how can I make it only run when a button is clicked?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class MoneyBtn : MonoBehaviour
{
// Use this for initialization
void Start()
{
var cash = 0;
cash = cash + 1;
GameObject.FindWithTag("MoneyTxt").GetComponent<Text>().text = "Hello";
}
}
1.Public method Check
2.Renamed
3.
Went to onclick
4.(Script was already attached)
5.Script is attached to object already, should I move it?
6. Method doesn’t pop up… Current Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class MoneyBtnScript : MonoBehaviour
{
// Use this for initialization
public void Start()
{
var cash = 0;
}
public void Click()
{
GameObject.FindWithTag("MoneyTxt").GetComponent<Text>().text = "Hello";
}
}