当前位置:网站首页>[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 :

边栏推荐
- Chendanqi, Fang Fei, guquanquan and Li Bo won the prize, and the list of Sloan research award in 2022 was released
- Two writing methods of JNI function
- Android应用安全之JNI混淆
- Leetcode 48. 旋转图像(可以,已解决)
- Batch will png . bmp . JPEG format pictures are converted to Jpg format picture
- Web3 security serials (3) | in depth disclosure of NFT fishing process and prevention techniques
- Remoteviews layout and type restriction source code analysis
- SHA256加密工具类
- MapReduce project case 1
- [C language] use of nested secondary pointer of structure
猜你喜欢

最新汇总!30省份公布2022高考分数线

建立自己的网站(18)

Software test interview classic + 1000 high-frequency real questions, and the hit rate of big companies is 80%

Data analysis learning notes

Web3 security serials (3) | in depth disclosure of NFT fishing process and prevention techniques

Many benefits of SEO optimization are directly related to traffic

多维度监控:智能监控的数据基础

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

Prepare for Jin San Yin Si I. testers without experience in automated testing projects should look at it quickly

Necessary for beginners PR 2021 quick start tutorial, PR green screen matting operation method
随机推荐
【C语言】关于scanf()与scanf_s()的一些问题
Convert black mask picture to color annotation file
Source code analysis of ArrayList
Zero basic C language (I)
How to get a generic type
.NET混合开发解决方案24 WebView2对比CefSharp的超强优势
PyQt5可视化开发
fatal: unsafe repository (‘/home/anji/gopath/src/gateway‘ is owned by someone else)
EMC RS485 interface EMC circuit design scheme
What is data compliance? How to achieve data compliance?
[C language] about scanf() and scanf_ Some problems of s()
什么是数据合规?怎样做到数据合规?
[Beijing University of Aeronautics and Astronautics] information sharing for the first and second examinations of postgraduate entrance examination
3. seat number
Using MySQL database in the express framework of node
AcWing 610. Salary and bonus (implemented in C language)
设置Canvas的 overrideSorting不生效
Many benefits of SEO optimization are directly related to traffic
双缓冲绘图
6. calculation index