当前位置:网站首页>Unity Editor Extension Foundation, editorguilayout (III)
Unity Editor Extension Foundation, editorguilayout (III)
2022-06-28 12:21:00 【Unique_ eight hundred and forty-nine million nine hundred and n】
Summary :
1、 There are ways to draw a drop-down box DropdownButton、EnumMaskField、EnumPopup、IntPopup、Popup、EnumMaskPopup、MaskField,DropdownButton More trouble ,EnumMaskField、EnumMaskPopup、MaskField You can choose more than one .
2、 draw Slider It makes no difference , It's just MinMaxSlider Is the value range .
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
/// <summary>
/// Unity 5.6
/// </summary>
public class EditorGUILayoutOtherExample : EditorWindow
{
//PropertyField GetControlRect PrefixLabel
[MenuItem("EditorGUILayout/EditorGUILayoutOtherExample")]
static void Init()
{
EditorGUILayoutOtherExample window = (EditorGUILayoutOtherExample)EditorWindow.GetWindow(typeof(EditorGUILayoutOtherExample));
window.Show();
}
#region DropdownButton
private string m_itemString = "";
#endregion
#region EnumMaskField
public enum Example
{
Option_One = 1, //bits: 0000 0001
Option_Two = 2, //bits: 0000 0010
Option_Three = 4 //bits: 0000 0100
}
Example staticFlagMask = 0;
#endregion
#region EnumPopup
public enum OPTIONS
{
CUBE = 0,
SPHERE = 1,
PLANE = 2
}
public OPTIONS op;
#endregion
#region IntPopup
int selectedSize = 1;
string[] names = new string[] { "Normal", "Double", "Quadruple" };
int[] sizes = new int[]{1, 2, 4};
#endregion
#region Popup
public string[] options = new string[] { "Cube", "Sphere", "Plane" };
public int index = 0;
#endregion
#region EnumMaskPopup
public enum Options
{
CUBE = 0,
SPHERE = 1,
PLANE = 2
}
public Options m_options;
#endregion
#region InspectorTitlebar
bool fold = true;
bool fold2 = true;
Transform selectedTransform;
GameObject selectedGameObject;
#endregion
#region IntSlider
int m_intSlider = 1;
#endregion
#region IntSlider
float scale = 0.0f;
#endregion
#region MinMaxSlider
float minVal = -10;
float maxVal = 10;
float minLimit = -20;
float maxLimit = 20;
#endregion
#region PasswordField
string m_passwordField = "";
#endregion
void OnGUI()
{
#region DropdownButton
// More trouble
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("DropdownButton:");
if (EditorGUILayout.DropdownButton(new GUIContent(m_itemString), FocusType.Keyboard))
{
var alls = new string[4] { "A", "B", "C", "D" };
GenericMenu _menu = new GenericMenu();
foreach (var item in alls)
{
if (string.IsNullOrEmpty(item))
{
continue;
}
// Add menu
_menu.AddItem(new GUIContent(item), m_itemString.Equals(item), OnValueSelected, item);
}
_menu.ShowAsContext();// Show menu
}
EditorGUILayout.EndHorizontal();
#endregion
#region EnumMaskField
// You can choose more than one
staticFlagMask = (Example)EditorGUILayout.EnumMaskField("EnumMaskField:", staticFlagMask);
#endregion
#region EnumPopup
op = (OPTIONS)EditorGUILayout.EnumPopup("EnumPopup:", op);
#endregion
#region IntPopup
selectedSize = EditorGUILayout.IntPopup("IntPopup: ", selectedSize, names, sizes);
#endregion
#region Popup
index = EditorGUILayout.Popup("Popup:",index, options);
#endregion
#region EnumMaskPopup
m_options = (Options)EditorGUILayout.EnumMaskPopup("EnumMaskPopup:", m_options);
#endregion
#region HelpBox
EditorGUILayout.HelpBox("HelpBox Error:", MessageType.Error);
EditorGUILayout.HelpBox("HelpBox Info:", MessageType.Info);
EditorGUILayout.HelpBox("HelpBox None:", MessageType.None);
EditorGUILayout.HelpBox("HelpBox Warning:", MessageType.Warning);
#endregion
#region InspectorTitlebar
selectedTransform = Selection.activeGameObject.transform;
selectedGameObject = Selection.activeGameObject;
fold = EditorGUILayout.InspectorTitlebar(fold, selectedTransform);
fold2 = EditorGUILayout.InspectorTitlebar(fold2, selectedGameObject);
#endregion
#region IntSlider
// Including the maximum and minimum values
m_intSlider = EditorGUILayout.IntSlider("IntSlider:",m_intSlider, 1, 10);
#endregion
#region MinMaxSlider
// Value range
EditorGUILayout.LabelField("Min Val:", minVal.ToString());
EditorGUILayout.LabelField("Max Val:", maxVal.ToString());
EditorGUILayout.MinMaxSlider("MinMaxSlider",ref minVal, ref maxVal, minLimit, maxLimit);
#endregion
EditorGUILayout.Space();
#region PasswordField
m_passwordField = EditorGUILayout.PasswordField("PasswordField:", m_passwordField);
EditorGUILayout.LabelField(" Text entered :", m_passwordField);
#endregion
#region SelectableLabel
// You can choose , Copy and paste
EditorGUILayout.SelectableLabel("SelectableLabel");
#endregion
scale = EditorGUILayout.Slider("Slider:",scale, 1, 100);
// Adaptive high , Can't adapt to wide
m_textArea = EditorGUILayout.TextArea(m_textArea);
m_vector2 = EditorGUILayout.Vector2Field("Vector2:", m_vector2);
m_vector3 = EditorGUILayout.Vector3Field("Vector3:", m_vector3);
m_vector4 = EditorGUILayout.Vector4Field("Vector4:", m_vector4);
}
string m_textArea = "";
Vector2 m_vector2;
Vector3 m_vector3;
Vector4 m_vector4;
#region DropdownButton
void OnValueSelected(object value)
{
m_itemString = value.ToString();
}
#endregion
}
Come here ,5.6 Version of EditorGUILayout All methods of class have been tried .
design sketch :

边栏推荐
- 【vi/vim】基本使用及命令汇总
- Is tongdaxin stock software reliable? Is it safe to trade stocks on it?
- Unity导入资源后还手动修改资源的属性?这段代码可以给你节约很多时间:AssetPostprocessor
- AcWing 609. Salary (implemented in C language)
- 已知两个点和中间一个比例的点,求该点坐标
- 【C语言】二叉树的实现及三种遍历
- EMC RS485接口EMC电路设计方案
- 深度学习又有新坑了!悉尼大学提出全新跨模态任务,用文本指导图像进行抠图...
- 不到一小时,苹果摧毁了15家初创公司
- 期货开户有门槛吗,如何网上安全的开通期货账户
猜你喜欢

RemoteViews的作用及原理

Prefix and (2D)

内部振荡器、无源晶振、有源晶振有什么区别?

Self use demo of basic component integration of fluent

智联招聘基于 Nebula Graph 的推荐实践分享

Necessary for beginners PR 2021 quick start tutorial, PR green screen matting operation method

UGUI使用小技巧(六)Unity实现字符串竖行显示
![[C language] use of nested secondary pointer of structure](/img/59/8b61805431e152995c250f6dd08e29.png)
[C language] use of nested secondary pointer of structure

Web3安全连载(3) | 深入揭秘NFT钓鱼流程及防范技巧

Swin, three degrees! Eth open source VRT: a transformer that refreshes multi domain indicators of video restoration
随机推荐
搭建学习环境
零基础C语言(一)
If you want to change to software testing, how can you package your resume as a test engineer with 1 year of work experience
[C language] use of file read / write function
cdc同步 如果数据库表的主键发生了变化,会同步成两个数据 还是会同步更新主键呢?
洛谷_P1303 A*B Problem_高精度计算
Web3安全连载(3) | 深入揭秘NFT钓鱼流程及防范技巧
AcWing 605. Simple product (implemented in C language)
【C语言】随机数文件对其进行三种排序方法
.NET混合开发解决方案24 WebView2对比CefSharp的超强优势
自定义标题栏View
AcWing 604. Area of circle (implemented in C language)
建立自己的网站(18)
AcWing 607. Average 2 (implemented in C language)
Levels – virtual engine scene production "suggestions collection"
What is the difference between internal oscillator, passive crystal oscillator and active crystal oscillator?
华泰证券开户安全吗? 开户有风险吗
【Unity编辑器扩展实践】、利用txt模板动态生成UI代码
6.A-B
4. maximum continuity factor