Hello
I tried to do this using a public variable but for some reasons if I use the variable the values are not updating.
Also I tried to pass values into Rect from variables but I get an error.
public class MainMenuGUI : MonoBehaviour
{
//Buttons Variables
public float btnWidth = Screen.width / (float)1.66;
public float btnHeight = Screen.width / 7;
public float heightPos = 150;
public Rect buttonRect = new Rect(Screen.width / 2 - (Screen.width / (float)1.66) / 2 + 50, Screen.height / 2 - 25, btnWidth , btnHeight);
void OnGUI()
{
if (GUI.Button(new Rect(Screen.width / 2 - (Screen.width / (float)1.66) / 2, Screen.height / 2 - (Screen.width / 7) - 100, Screen.width / (float)1.66, Screen.width / 7), "Play"))
{
print("You clicked the button!");
}
}
}
The errors I get when I pass variables into new Rect instead of the actual value.