As the title says, I can’t do anything to make it work:(.If I press the button,I want it to add 1 to the total number of currentprogr, but to later use the variable.Now, it shows the changeble text, but the button doesn’t find any function in the class Hire_programmers or GameMechanics or Employees.I even assigned both scripts to the button.
Here is my code:
The main c#:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Employees
{
public static int currentprogr=0;
}
public class GameMechanics : MonoBehaviour {
GameObject currentpr;
Text curprogr;
void Start{
myTextgameObject = GameObject.Find("Datetext");
currentpr = GameObject.Find("currentprogr");
}
void FixedUpdate{
curprogr = currentpr.GetComponent<Text>();
curprogr.text = "Current programmers:"+Employees.currentprogr;
}
}
The button code:
using UnityEngine;
using System.Collections;
public class Hire_programmers : MonoBehaviour {
void OnMouseDown()
{
Employees.currentprogr++;
}
}
Thank you in advance for your cooperation. Peace!:)