赞
踩
编辑器中的GUI系统,我们可以分为四大类:
1、UnityEngine.GUI
2、UnityEngine.GUILayout
3、UnityEditor.EditorGUI
4、UnityEditor.EditorGUILayout
1和2所属的命名空间是UnityEngine
3和4所述的命名空间是UnityEditor
下面展示一下每一个的用法,具体的每一个类的函数不会全部列出来,在API中可以自己查找。
1
GUI需要自己去设计布局
private Void OnGUI()
{
GUI.Button(new Rect(0,0,100,30),"one Button");
GUI.Label(new Rect(100, 0, 100, 30), "Label");
GUI.PasswordField(new Rect(0, 30, 100, 30), "Password", '$');
GUI.Toggle(new Rect(100, 30, 100, 30), true, "Toggle");
}
2
GUILayout带有自适应的布局,相对的适应性要差了一些
private void OnGUI()
{
GUILayout.BeginHorizontal("Box"); //开始一个水平布局
GUILayout.Button("Button");
GUILayout.Label("Label");
GUILayout.PasswordField("Password"
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。