[Unity]GUILayout center learn

GUILayout center Code:

just change red word to your UI script.It's very easy.

如何讓GUILayout裡面的UI置中呢?

只要修改紅色的程式碼在其中加入你的UI程式碼即可

void OnGUI()
{
GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));
GUILayout.FlexibleSpace();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();

//Your UI START

GUILayout.Button("OK");

//Your UI  END

GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.FlexibleSpace();
GUILayout.EndArea();

}