using UnityEngine;
using System.Collections;
public class GuiLayerOutTest : MonoBehaviour
{
// Use this for initialization
private string editName;
void Start ()
{
editName = "请输入文本";
}
// Update is called once per frame
void Update ()
{
}
void OnGUI()
{
//定义区域
GUILayout.BeginArea (new Rect (20, 20, 300, 300));
//水平布局
GUILayout.BeginHorizontal ();
//垂直布局
GUILayout.BeginVertical ();
GUILayout.Box ("水平测试111");
GUILayout.FlexibleSpace ();
GUILayout.Box ("测试1");
GUILayout.EndVertical ();
//插入一个弹性空白 盛满整个剩余空间
GUILayout.FlexibleSpace ();
GUILayout.BeginVertical ();
GUILayout.Box ("水平测试222");
GUILayout.Box ("测试2");
GUILayout.EndVertical ();
GUILayout.Box ("开始水平布局");
GUILayout.Label ("水平文本");
GUILayout.Space (10);
GUILayout.Button ("按钮");
GUILayout.TextField ("输入框");
GUILayout.EndHorizontal ();
//设置间隔
GUILayout.Space (20);
GUILayout.BeginVertical ();
GUILayout.Box ("开始垂直布局");
GUILayout.Label("垂直文本");
GUILayout.Button ("按钮");
editName = GUILayout.TextField (editName);
GUILayout.EndVertical ();
GUILayout.EndArea ();
}
}
using System.Collections;
public class GuiLayerOutTest : MonoBehaviour
{
// Use this for initialization
private string editName;
void Start ()
{
editName = "请输入文本";
}
// Update is called once per frame
void Update ()
{
}
void OnGUI()
{
//定义区域
GUILayout.BeginArea (new Rect (20, 20, 300, 300));
//水平布局
GUILayout.BeginHorizontal ();
//垂直布局
GUILayout.BeginVertical ();
GUILayout.Box ("水平测试111");
GUILayout.FlexibleSpace ();
GUILayout.Box ("测试1");
GUILayout.EndVertical ();
//插入一个弹性空白 盛满整个剩余空间
GUILayout.FlexibleSpace ();
GUILayout.BeginVertical ();
GUILayout.Box ("水平测试222");
GUILayout.Box ("测试2");
GUILayout.EndVertical ();
GUILayout.Box ("开始水平布局");
GUILayout.Label ("水平文本");
GUILayout.Space (10);
GUILayout.Button ("按钮");
GUILayout.TextField ("输入框");
GUILayout.EndHorizontal ();
//设置间隔
GUILayout.Space (20);
GUILayout.BeginVertical ();
GUILayout.Box ("开始垂直布局");
GUILayout.Label("垂直文本");
GUILayout.Button ("按钮");
editName = GUILayout.TextField (editName);
GUILayout.EndVertical ();
GUILayout.EndArea ();
}
}