I am making my first game, and I am having trouble updating a bool value using a toggle button.
This is the button:
using UnityEngine;
using Assets.Code.Interfaces;
using Assets.Code.Scripts;
using Assets.Code.PowerPlants;
namespace Assets.Code.States
public void ShowIt()
{
HydroElectric.t1Bool = GUI.Toggle (new Rect (25, 55, 100, 50), HydroElectric.t1Bool, "Turbina 2 MW");
GUI.Box (new Rect (Screen.width - 100, 60, 80, 25), HydroElectric.prod.ToString ()); // PRODUCED ENERGY
}
This is where I have the if condition:
using System;
namespace Assets.Code.PowerPlants
public class HydroElectric
{
public static bool t1Bool = true;
public int turbina1;
public static float prod = 0;
public HydroElectric ()
{
if (t1Bool == true)
{
turbina1 = 2;
}
else
{
turbina1 =0;
}
prod = turbina1;
}
}
I have no errors on the console, the bool value is changing (I used debug) but the value of turbina1 is not changing (when I debug it from the first script). I have no idea why its value is not changing along with the true or false condition. Any idea?