I have a script and i get no errors or warnings but when i run it but it still wont run correctly. I set up the input tags but still nothing. I don't know if i'm even allowed to try to do what i'm running but i don't see why not. I used to have it two different script but because it has to modify stuff that is contained on the other script i don't want to have to deal with special variables. But once again i want to be able to open up a gui with the push of a button... And btw if you know can you tell be how i can make a default job... As in the first time you join the game you are set to a citizen... I think its already applied but there isnt a script to make sure. thanks in advanced.
Here is the script i have now...
using UnityEngine;
using System.Collections;
public class JobInfo : MonoBehaviour {
public int curMoney = 1000;
public int curHealth = 100;
public int maxHealth = 100;
public string curJob;
public int Salary = 50;
public int payTime = 180;
public float healthBarLength;
void Start () {
InvokeRepeating ("AddMoney", payTime, payTime);
healthBarLength = Screen.width / 2;
}
// Update is called once per frame
void Update () {
AdjustCurrentHealth(0);
}
void OnGUI() {
Jobs();
GUI.Label (new Rect (10, 10, 100, 30), "Job: ");
GUI.Label (new Rect (35, 10, 100, 30), curJob);
GUI.Label (new Rect (80, 10, 100, 30), "| Salary: ");
GUI.Label (new Rect (130, 10, 100, 30), Salary.ToString());
GUI.Label (new Rect (150, 10, 100, 30), "| Money: ");
GUI.Label (new Rect (200, 10, 100, 30), curMoney.ToString());
GUI.Box(new Rect(10, Screen.height - 30, healthBarLength, 20), curHealth + "/" + maxHealth);
}
public void AdjustCurrentHealth(int adj) {
curHealth +=adj;
if(curHealth < 1)
curHealth = 0;
if(curHealth > maxHealth)
curHealth = maxHealth;
if(maxHealth < 1)
maxHealth = 1;
healthBarLength = (Screen.width / 2) * (curHealth / (float)maxHealth);
}
void AddMoney ()
{
curMoney += Salary;
}
public void Jobs() {
if(Input.GetButtonDown("Jobs"))
{
if (GUI.Button (new Rect (25, 25, 100, 30), "Citizen")) {
}
if (GUI.Button (new Rect (25, 50, 100, 30), "Salesman")) {
Salesman();
}
if (GUI.Button (new Rect (25, 75, 100, 30), "Cook")) {
}
if (GUI.Button (new Rect (25, 100, 100, 30), "Hitman")) {
// This code is executed when the Button is clicked
}
if (GUI.Button (new Rect (100, 25, 100, 30), "S.W.A.T.")) {
// This code is executed when the Button is clicked
}
if (GUI.Button (new Rect (100, 50, 100, 30), "Police")) {
// This code is executed when the Button is clicked
}
if (GUI.Button (new Rect (100, 75, 100, 30), "Doctor")) {
// This code is executed when the Button is clicked
}
if (GUI.Button (new Rect (100, 100, 100, 30), "Mayor")) {
// This code is executed when the Button is clicked
}
}
}
public void Salesman () {
if (GUI.Button (new Rect (25, 50, 100, 30), "Gun Salesman")) {
// This code is executed when the Button is clicked
}
if (GUI.Button (new Rect (25, 50, 100, 30), "Car Salesman")) {
// This code is executed when the Button is clicked
}
if (GUI.Button (new Rect (25, 50, 100, 30), "Drug Salesman")) {
// This code is executed when the Button is clicked
}
}
}
But this is the part that i want you to look at
public void Jobs() {
if(Input.GetButtonDown("Jobs"))
{
if (GUI.Button (new Rect (25, 25, 100, 30), "Citizen")) {
}
if (GUI.Button (new Rect (25, 50, 100, 30), "Salesman")) {
Salesman();
}
if (GUI.Button (new Rect (25, 75, 100, 30), "Cook")) {
}
if (GUI.Button (new Rect (25, 100, 100, 30), "Hitman")) {
// This code is executed when the Button is clicked
}
if (GUI.Button (new Rect (100, 25, 100, 30), "S.W.A.T.")) {
// This code is executed when the Button is clicked
}
if (GUI.Button (new Rect (100, 50, 100, 30), "Police")) {
// This code is executed when the Button is clicked
}
if (GUI.Button (new Rect (100, 75, 100, 30), "Doctor")) {
// This code is executed when the Button is clicked
}
if (GUI.Button (new Rect (100, 100, 100, 30), "Mayor")) {
// This code is executed when the Button is clicked
}
}
}
public void Salesman () {
if (GUI.Button (new Rect (25, 50, 100, 30), "Gun Salesman")) {
// This code is executed when the Button is clicked
}
if (GUI.Button (new Rect (25, 50, 100, 30), "Car Salesman")) {
// This code is executed when the Button is clicked
}
if (GUI.Button (new Rect (25, 50, 100, 30), "Drug Salesman")) {
// This code is executed when the Button is clicked
}
}