赞
踩
基本每个控件方法都有一个可选参数是GUILayoutOption[] Options 这是一个可以控制组件大小之类的选项,在GUILayout类中共有8个。
GUILayout.Height() GUILayout.Width()
GUILayout.MaxHeight() GUILayout.MaxWidth()
GUILayout.MinHeight() GUILayout.MinWidth()
GUILayout.ExpandHeight() GUILayout.ExpandWidth()
GUILayout.Box(new GUIContent("一个200x200的BOX"),new []{GUILayout.Height(200),GUILayout.Width(200)});
num = EditorGUILayout.Slider ("Slider", num, -3, 3);
- scrollBarValue1 = GUILayout.HorizontalScrollbar(scrollBarValue1,0,0,100,new[]{GUILayout.Width(100)});
- scrollBarValue2 = GUILayout.VerticalScrollbar(scrollBarValue2,0,0,100,new[]{GUILayout.Height(100)});
- scrollValue1=GUILayout.HorizontalSlider(scrollValue1, 0, 100);
- scrollValue2=GUILayout.VerticalSlider(scrollValue2, 0, 100);
gridId = GUILayout.SelectionGrid(gridId, new[] {"1", "2", "3","4","5","6"}, 4);
toolbarid=GUILayout.Toolbar(toolbarid, new[] {"1", "2", "3"});
- GUILayout.TextField("TextField只能一行");
- GUILayout.TextArea("TextArea可以多行\n 第二行");
password = GUILayout.PasswordField(password, '*');
- //保证块里写的控件只在Area规定的范围内,这里设置放到右下角
- GUILayout.BeginArea(new Rect(position.width-250,position.height-150,250,150));
- //...
- GUILayout.EndArea();
-
-
-
- GUILayout.BeginHorizontal();
- //...水平布局
- GUILayout.EndHorizontal();
-
- GUILayout.BeginVertical();
- //...垂直布局
- GUILayout.EndVertical();
-
-
- //显示的范围不够块内控件时可以滑动 这里限制高度75最多同时显示3个
- scrollPos=GUILayout.BeginScrollView(scrollPos,false,true,GUILayout.Height(75));
- //...
- GUILayout.EndScrollView();
- groupEnabled = EditorGUILayout.BeginToggleGroup ("ToogleGroup",groupEnabled);
- //...
- EditorGUILayout.EndToggleGroup ();
- //可以选择一个最大最小的范围的slider
- EditorGUILayout.MinMaxSlider("MinMaxSlider",ref sliderValue2,ref sliderValue3,10,20);
- //int类型的slider
- intSliderValue=EditorGUILayout.IntSlider(intSliderValue,0,10);
- //和guilayout重复的
- sliderValue=EditorGUILayout.Slider(sliderValue,0f,1);
- //这个可以多选 需要枚举类型
- flagtype=(flagTestType)EditorGUILayout.EnumFlagsField(flagtype);
- //这个单选 需要枚举类型
- popuptype=(popupTestType)EditorGUILayout.EnumPopup(popuptype);
- //一个选择框,每个选择框里表示一个Int数
- popupindex=EditorGUILayout.IntPopup("IntPopup", popupindex, new[] {"a", "b"}, new[] {1, 2});
- //和IntPopup类似但是可以多选
- maskindex=EditorGUILayout.MaskField("Mask",maskindex,new []{"a","b"});
- i1=EditorGUILayout.IntField("IntField",i1,GUILayout.Width(100));
- d1=EditorGUILayout.DoubleField("DoubleField",d1,GUILayout.Width(100));
-
- //bounds类型输入框 反正就两个三维向量
- boundsv=EditorGUILayout.BoundsField("BoundsField",boundsv);
- boundintv=EditorGUILayout.BoundsIntField("BoundsIntField",boundintv);
-
- //层级和标签\物体选择,就是unity中的各种layer tag gameboject
- EditorGUILayout.LayerField("LayerField", 1);
- EditorGUILayout.TagField("TagField", "一个tag");
- EditorGUILayout.ObjectField("ObjectField",GameObject.Find("Cube"), typeof(GameObject),true);
-
- //显示序列化属性字段 比如之前的自定义特性里的
- EditorGUILayout.PropertyField(p)
-
- EditorGUILayout.RectField(new Rect());
- EditorGUILayout.RectIntField(new RectInt());
-
- //delay和一般的区别是只有按下回车或者失去焦点时,才会返回值,就是说你再输入时不会返回
- //Note that the return value will not change until the user has pressed enter or focus is moved away from the text field.
- delayint=EditorGUILayout.DelayedIntField("DelayedInt",delayint);
- delayfloat=EditorGUILayout.DelayedFloatField("DelayedFloat",delayfloat);
- delaydouble=EditorGUILayout.DelayedDoubleField("DelayedDouble",delaydouble);
- delaystr=EditorGUILayout.DelayedTextField("DelayedTextField",delaystr);
-
- colorv=EditorGUILayout.ColorField("颜色框", colorv);
- acurev=EditorGUILayout.CurveField("曲线", acurev);
-
- //还有这几个向量
- //EditorGUILayout.Vector2Field();
- //EditorGUILayout.Vector2IntField();
- //EditorGUILayout.Vector3Field();
- //EditorGUILayout.Vector3IntField();
- //EditorGUILayout.Vector4Field()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。