Hi i have my gui for changing the controls how would i go about centering it?
using UnityEngine;
using System.Collections;
public class Gui : MonoBehaviour {
private Vector2 _scrollPosition = new Vector2();
public bool ShowMenu;
float native_width = 800;
float native_height = 600;
void Update()
{
if(Input.GetKeyDown(KeyCode.Escape))
{
ShowMenu = !ShowMenu;
}
}
void OnGUI()
{
float rx = Screen.width / native_width;
float ry = Screen.height / native_height;
GUI.matrix = Matrix4x4.TRS (new Vector3(0f, 0f, 0f), Quaternion.identity, new Vector3(rx, ry, 1f));
if (ShowMenu == true)
{
_scrollPosition = GUILayout.BeginScrollView(_scrollPosition);
GUILayout.BeginHorizontal();
GUILayout.BeginVertical();
GUILayout.Label("Action");
for (int n = 0; n < cInput.length; n++)
{
GUILayout.Label(cInput.GetText(n, 0));
}
GUILayout.EndVertical();
GUILayout.BeginVertical();
GUILayout.Label("Primary");
for (int n = 0; n < cInput.length; n++)
{
if (GUILayout.Button(cInput.GetText(n, 1)) && Input.GetMouseButtonUp(0))
{
cInput.ChangeKey(n, 1);
}
}
GUILayout.EndVertical();
GUILayout.BeginVertical();
GUILayout.Label("Secondary");
for (int n = 0; n < cInput.length; n++)
{
if (GUILayout.Button(cInput.GetText(n, 2)) && Input.GetMouseButtonUp(0))
{
cInput.ChangeKey(n, 2);
}
}
GUILayout.EndVertical();
GUILayout.EndHorizontal();
GUILayout.EndScrollView();
GUILayout.BeginHorizontal();
if (GUILayout.Button("Reset to Defaults") && Input.GetMouseButtonUp(0))
{
cInput.ResetInputs();
}
if (GUILayout.Button("Close") && Input.GetMouseButtonUp(0))
{
ShowMenu = false;
}
GUILayout.EndHorizontal();
}
}
}
already knew i could do this im just not sure how to with my script as i use loops
– PvTGreg