As the title says, i cant get the elements inside OnGUI() to stay at the same position…i have tried to use GUI Matrix and many onther solutions but none of them actualy worked…this pretty much stops me from trying to develop any game, please help. ( i am mainly using c#)
You can use Screen.height and Screen.width to get the size of the screen, which can be used to position elements. example:
void OnGUI()
{
float buttonWidth = 100f;
float buttonHeight = 40f;
Rect rect = new Rect(Screen.width / 2 - buttonWidth / 2,
Screen.height / 2 - buttonHeight / 2,
buttonWidth,
buttonHeight);
if (GUI.Button(rect, "click me")) {
Debug.Log("clicked");
}
}