当前位置:网站首页>[unity Editor Extension Foundation], editorguilayout (I)
[unity Editor Extension Foundation], editorguilayout (I)
2022-06-28 12:21:00 【Unique_ eight hundred and forty-nine million nine hundred and n】
Summary :
1、EditorGUILayout Various Field and GUILayout Similar , however EditorGUILayout You can copy and paste ;
2、 because OnGUI Is executed every frame ,EditorGUILayout It's similar to TextField、IntSlider、ColorField Need to pass a value , Returns the modified value , You need to assign the return value to a temporary variable ;
3、params GUILayoutOption[] options The parameters that can be passed are GUILayout Class : GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
4、DelayedField Delayed input fields Before pressing the Enter key or moving the focus away from the text field , No new value will be returned .
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class EditorGUILayoutFieldExample : EditorWindow
{
#region Field
//BoundsField
static Vector3 center = new Vector3(1, 2, 3);
static Vector3 size = new Vector3(1, 2, 3);
Bounds _bounds = new Bounds(center, size);
//ColorField
Color m_color = Color.white;
//CurveField
AnimationCurve m_curve = AnimationCurve.Linear(0, 0, 10, 10);
//DelayedDoubleField DelayedFloatField DelayedIntField DelayedTextField
double m_delayedDouble = 0;
float m_delayedFloat = 0;
int m_delayedInt = 0;
string m_delayedString = "";
//DoubleField FloatField IntField TextField
double m_fieldDouble = 0;
float m_fieldFloat = 0;
int m_fieldInt = 0;
string m_fieldString = "";
long m_fieldLong = 0;
//LayerField
int selectedLayer = 0;
//ObjectField
Object m_fieldObject;
//MaskField
int flags = 0;
string[] options = new string[] { "CanJump", "CanShoot", "CanSwim" };
//TagField
string tagStr = "Untagged";
//RectField
Rect m_rectFieldPos;
#endregion
[MenuItem("EditorGUILayout/EditorGUILayoutFieldExample")]
static void Init()
{
EditorGUILayoutFieldExample window = (EditorGUILayoutFieldExample)EditorWindow.GetWindow(typeof(EditorGUILayoutFieldExample));
window.Show();
}
void OnGUI()
{
#region Field Input box
//BoundsField Boundary input box
_bounds = EditorGUILayout.BoundsField("BoundsField:",_bounds);
//ColorField Color input box
m_color = EditorGUILayout.ColorField("ColorField:",m_color);
//CurveField Curve input box
m_curve = EditorGUILayout.CurveField("CurveField:", m_curve);
//DelayedField
m_delayedDouble = EditorGUILayout.DelayedDoubleField("DelayedDoubleField:", m_delayedDouble);
m_delayedFloat = EditorGUILayout.DelayedFloatField("DelayedFloatField:", m_delayedFloat);
m_delayedInt = EditorGUILayout.DelayedIntField("DelayedIntField:", m_delayedInt);
m_delayedString = EditorGUILayout.DelayedTextField("DelayedTextField:", m_delayedString);
m_fieldDouble = EditorGUILayout.DoubleField("DoubleField:", m_fieldDouble);
m_fieldFloat = EditorGUILayout.FloatField("FloatField:", m_fieldFloat);
m_fieldInt = EditorGUILayout.IntField("IntField:", m_fieldInt);
m_fieldString = EditorGUILayout.TextField("TextField:", m_fieldString);
m_fieldLong = EditorGUILayout.LongField("LongField:", m_fieldLong);
//LabelField
EditorGUILayout.LabelField(" This is a LabelField! ");
//LayerField You can get all of Layer
selectedLayer = EditorGUILayout.LayerField("LayerField:", selectedLayer);
//ObjectField
m_fieldObject = EditorGUILayout.ObjectField(m_fieldObject, typeof(Object), true);
//MaskField
flags = EditorGUILayout.MaskField("MaskField:", flags, options);
//RectField
m_rectFieldPos = EditorGUILayout.RectField("RectField:", m_rectFieldPos);
//TagField
tagStr = EditorGUILayout.TagField("TagField:", tagStr);
#endregion
}
}
That's all EditorGUILayout All kinds of Field The use of .
design sketch :

边栏推荐
猜你喜欢

EMC RS485 interface EMC circuit design scheme

. Net hybrid development solution 24 webview2's superior advantages over cefsharp

Share the easy-to-use fastadmin open source system - practical part

KDD 2022 | 图“预训练、提示、微调”范式下的图神经网络泛化框架

Source code analysis of ArrayList

纯纯大怨种!那些年被劝退的考研专业

【Unity编辑器扩展实践】、利用txt模板动态生成UI代码
Using MySQL database in the express framework of node

RemoteViews的作用及原理

【Unity编辑器扩展实践】、通过代码查找所有预制
随机推荐
MapReduce项目案例1
AsyncTask经验小结
ByteV搭建动态数字孪生网络安全平台----助力网络安全发展
How to get a generic type
Research on personalized product search
What is data compliance? How to achieve data compliance?
[C language] about scanf() and scanf_ Some problems of s()
Prefix and (2D)
Build your own website (18)
Share the easy-to-use fastadmin open source system - practical part
【Unity编辑器扩展基础】、GUI
【C语言】文件读写函数使用
2. single digit statistics
AcWing 608. Poor (implemented in C language)
What are the common modes of financial products in 2022?
Levels – 虚幻引擎场景制作「建议收藏」
如何获取泛型的类型
MapReduce项目案例3——温度统计
华泰证券开户安全吗? 开户有风险吗
4. maximum continuity factor