(C#)I have looked through a lot of other posts on here and none of them relate to GUI Labels like mine does. So, what I am trying to do is, I have a variable in one script that has a value of whatever, say 4, then I want to transfer that variable/value to another script where it hold my GUI Label to show that value. The code is below. Script 1:
public float newsPapersSold;
// Use this for initialization
void Start () {
newsPapersSold = 0;
}
// Update is called once per frame
void Update () {
}
public void NPClick()
{
newsPapersSold ++;
Debug.Log("NP: " + newsPapersSold);
}
}
Script 2:
public float newspapersSold;
public GUIStyle npSoldGUI;
public Button newspaperBtn;
// Use this for initialization
void Start()
{
newspapersSold = GetComponent<SellNewsPaper>().newsPapersSold;
}
// Update is called once per frame
void Update()
{
}
public void OnGUI()
{
GUI.Label(new Rect(480, -25, 800, 200), "Newspapers Sold: " + newspapersSold, npSoldGUI);
}
}