Hey i have tried everything i know on how to position the GUI in my code in the right spot depending on the resolution and still something is wrong. I built the game and now the GUI is all to the left and not positioned where i put it in the editor. Any Help would be nice thanks.
-Christian j
code:
using UnityEngine;
using System.Collections;
public class GameMenu : MonoBehaviour {
private bool mainMenuActive;
private bool newGame = false;
private bool loadGame = false;
private bool onlineGame = false;
private bool gameOptions = false;
private bool gameUpdates = false;
void Start()
{
mainMenuActive = true;
}
void OnGUI()
{
if(mainMenuActive == true)
{
MainMenu();
}
//MenuPlayerChoiceGUI
}
void MainMenu()
{
//Top-Bottom Bars
GUI.Box (new Rect (Screen.width /2 - 688, Screen.height /2 + 275, 8000, 50), "");
GUI.Box (new Rect (Screen.width /2 - 688, Screen.height /2 - 330, 8000, 50), "");
//Buttons
if (GUI.Button (new Rect (Screen.width / 2 - 600 , Screen.height / 2 - 315, 100, 30), "New Game"))
{
NewGame();
}
if(GUI.Button (new Rect (Screen.width / 2 - 480, Screen.height / 2 - 315, 100, 30), "Load Game"))
{
LoadGame();
}
if(GUI.Button (new Rect (Screen.width / 2 - 360, Screen.height / 2 - 315, 100, 30), "Online"))
{
Online();
}
if (GUI.Button (new Rect (Screen.width / 2 - 240, Screen.height / 2 - 315, 100, 30), "Options"))
{
Options();
}
if(GUI.Button (new Rect (Screen.width / 2 - 120, Screen.height / 2 - 315, 100, 30), "Updates"))
{
Updates();
}
if (GUI.Button (new Rect (Screen.width / 2 - 0, Screen.height / 2 - 315, 100, 30), "Exit"))
{
Application.Quit();
}
//Game Version
GUI.Label (new Rect (Screen.width / 2 - 0, Screen.height / 2 + 320, 100, 30), "Alpha 1.0");
}
void NewGame()
{
GUI.Box (new Rect (Screen.width / 2 + 100, Screen.height / 2 - 275, 500, 545), "");
}
void LoadGame()
{
GUI.Box (new Rect (Screen.width / 2 + 100, Screen.height / 2 - 275, 500, 545), "");
}
void Online()
{
GUI.Box (new Rect (Screen.width / 2 + 100, Screen.height / 2 - 275, 500, 545), "");
}
void Options()
{
GUI.Box (new Rect (Screen.width / 2 + 100, Screen.height / 2 - 275, 500, 545), "");
}
void Updates()
{
GUI.Box (new Rect (Screen.width / 2 + 100, Screen.height / 2 - 275, 500, 545), "");
}
}