I have this script:
public PlayState ()
{
HydroElectric ec = new HydroElectric();
}
public void ShowIt()
{
ec.t1Bool = GUI.Toggle (new Rect (25, 55, 100, 50), ec.t1Bool, "Turbina 2 MW");
ec.t2Bool = GUI.Toggle (new Rect (25, 95, 100, 50), ec.t2Bool, "Turbina 3 MW");
ec.t3Bool = GUI.Toggle (new Rect (25, 135, 100, 50), ec.t3Bool, "Turbina 1 MW");
GUI.Box (new Rect (Screen.width - 100, 60, 80, 25), ec.prod.ToString ()); // PRODUCED ENERGY
GUI.Box (new Rect (Screen.width - 650, 10, 100, 25), TimeManager.gametime.ToString() ); // GAME TIME HOURS
float test;
if (LoadDiagram.diagramaCarga.TryGetValue(TimeManager.gametime, out test)) // Returns true.
{
GUI.Box (new Rect (Screen.width - 650, 275, 50, 25), test.ToString ());
}
}
The problem is that I had to remove the Hydroelectric object out of the "ShowIt" method because it was being created everytime the toogle button was created, so I created a constructor to create the object, but now, the variable 'ec' is not recognized, what am I missing here?