Guys, I am trying to create an app that calculates hours for personal use but have hit a stupid snag. I am trying to multiply a set of numbers payRate*totalHours and have the sum show up under totalPay. When I click the button to calculate it the console prints 0 as the amount under the payrate. It completely ignores the code. I want to leave the totalPay and totalHours at 0 in the inspector and punch in the other stuff and have it tally up into the totals sections.
Here is my code:
public var hours: float = 0.0;
public var daysWorked: float = 0.0;
public var totalHours = hours * daysWorked;
public var payRate: float = 9.00;
public var totalPay: float = payRate * totalHours;
function Update()
{
//("working");
}
function OnGUI () {
if (GUI.Button (Rect (10,10,150,100), "Hours"))
{
print ("Calculating!");
DisplayAmount();
hours*=daysWorked;
}
else if(totalHours >= 1)
{
print("Not enough hours worked to calculate pay");
}
if (GUI.Button (Rect (10,110,150,100), "Pay"))
{
print ("Calculating!");
DisplayPay();
payRate*=totalHours;
}
}
function DisplayAmount ()
{
Debug.Log(totalHours);
}
function DisplayPay ()
{
Debug.Log(totalPay);
}