赞
踩
链接: https://docs.unity3d.com/cn/2019.4/ScriptReference/
public class MyWindow : EditorWindow//继承unity内置EditorWindow类 { [MenuItem("Window/我的自定义窗口")] private static void ShowWindow() { //1.用GetWindow方法创建的窗口,只可以打开一个 MyWindow window = GetWindow<MyWindow>("我的窗口");//字符串为窗口标题 //2.用CreateWindow方法创建的窗口,可以打开很多个 MyWindow window = CreateWindow<MyWindow>("我的窗口"); } private void OnGUI() { //GUI布局 } }
基础
GUILayout.Label("Label");
设置样式和大小
GUIStyle lblStyle = GUI.skin.label;//在unity默认的样式上面修改,如果使用new GUIStyle()的话,绘制出来的Label只有你自己设置的样式
lblStyle.alignment = TextAnchor.MiddleLeft;//
GUILayout.Label("Label", lblStyle, GUILayout.Width(50), GUILayout.Height(50));//必须指定大小,文字位置才有效
使用 GUIContent 代替文字
//无提示写法
GUIContent lblIcon = EditorGUIUtility.IconContent("console.infoicon");//根据icon名字获取unity内置的icon
GUILayout.Label(lblIcon);
//有提示写法
//(1)图标的提示:要加 |
GUIContent lblIcon = EditorGUIUtility.IconContent("console.infoicon", "|这是图标Label"
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。