当前位置:网站首页>Unity Editor Extension Foundation, GUI
Unity Editor Extension Foundation, GUI
2022-06-28 12:22:00 【Unique_ eight hundred and forty-nine million nine hundred and n】
One 、 Static attribute
1、 Color
Change the background color :GUI.backgroundColor
Change content color : GUI.contentColor
Change content change content and background color : GUI.color
// Change the background color
GUI.backgroundColor = Color.yellow;
GUI.Button(new Rect(0, 0, 200, 30), " Change the background color ");
GUI.backgroundColor = Color.white;
GUI.Button(new Rect(0, m_interval, 200, 30), " Change the background color ");
// Change content color
GUI.contentColor = Color.yellow;
GUI.Button(new Rect(0, m_interval * 2, 200, 30), " Change content color ");
GUI.contentColor = Color.white;
GUI.Button(new Rect(0, m_interval * 3, 200, 30), " Change content color ");
// Change the content and background color
GUI.color = Color.yellow;
GUI.Button(new Rect(0, m_interval * 4, 200, 30), " Change the content and background color ");
GUI.color = Color.white;
GUI.Button(new Rect(0, m_interval * 5, 200, 30), " Change the content and background color ");
2、 Text input box :GUI.TextField
GUI.changed: If the value of an input control changes , It will return true.
stringToEdit = GUI.TextField(new Rect(0, m_interval * 6, 200, 20), stringToEdit, 25);
if (GUI.changed)
Debug.Log("GUI.TextField The content has been modified. ");3、 GUI The activation state of :GUI.enabled
GUI.enabled After control GUI The activation state of , Not activated GUI Cannot receive events .
toggleGroup = GUI.Toggle(new Rect(0, m_interval * 7, 200, 20), toggleGroup, "ToggleGroup");
GUI.enabled = toggleGroup;
if (GUI.Button(new Rect(0, m_interval * 8, 200, 30), " test toggleGroup The button 1"))
{
Debug.Log(" Click. button1");
}
if (GUI.Button(new Rect(0, m_interval * 9, 200, 30), " test toggleGroup The button 2"))
{
Debug.Log(" Click. button2");
}
4、GUI.depth
5、GUI.matrix
6、GUI.skin
Two 、 Static methods
1、GUI.Label
GUI.Label(new Rect(210, 10, 100, 20), "Hello World!");2、 GUI.Box
GUI.Box(new Rect(210, 50, 50, 50), "A BOX");3、GUI.Button
if (GUI.Button(new Rect(210, 110, 70, 30), "A button"))
Debug.Log(" Click the button !");4、 GUI.BeginGroup
m_beginGroupRect = new Rect(0, 0, Screen.width / 2, Screen.height / 2);
//BeginGroup It can be used to manage UI,UGUI Of Panel, In the group UI Elements are created relative to groups .
GUI.BeginGroup(m_beginGroupRect);
GUI.Box(new Rect(m_beginGroupRect), " Adaptive BeginGroup test !");
GUI.EndGroup();5、GUI.BeginScrollView
// Sliding area
scrollPosition = GUI.BeginScrollView(new Rect(10, 10, 200, 200), scrollPosition, new Rect(0, 0, 220, 200));
GUI.Button(new Rect(0, 0, 100, 20), "Top-left");
GUI.Button(new Rect(120, 0, 100, 20), "Top-right");
GUI.Button(new Rect(0, 180, 100, 20), "Bottom-left");
GUI.Button(new Rect(120, 180, 100, 20), "Bottom-right");
GUI.EndScrollView();
6、 GUI.DrawTexture、GUI.DrawTextureWithTexCoords
// Draw a picture
if (aTexture)
{
GUI.DrawTexture(new Rect(10, 110, 110, 110), aTexture, ScaleMode.StretchToFill, true, 10.0F);
GUI.DrawTextureWithTexCoords(new Rect(10, 240, 110, 110), aTexture, new Rect(10, 240, 110, 110), false);
}7、 GUI.SetNextControlName
Set the control name for the next control .
8、 GUI.FocusControl
Set focus by control name , When setting focus, the parameter is the control name , When unfocusing, the parameter is null.(EditorGUILayout.TextField Control if it is focused , After the returned value is modified , It won't refresh right away , You need to unfocuse to see the refreshed value .)
GUI.SetNextControlName("MyTextField");
username = GUI.TextField(new Rect(10, 410, 100, 20), username);
pwd = GUI.TextField(new Rect(10, 440, 100, 20), pwd);
if (GUI.Button(new Rect(10, 470, 80, 20), " Set focus "))
GUI.FocusControl("MyTextField");
if (GUI.Button(new Rect(10, 500, 80, 20), " Unfocus "))
GUI.FocusControl(null);// Unfocus 9、GUI.HorizontalSlider、GUI.VerticalSlider、GUI.HorizontalScrollbar、GUI.VerticalScrollbar
hSliderValue = GUI.HorizontalSlider(new Rect(210, 150, 100, 30), hSliderValue, 0.0F, 10.0F);
vSliderValue = GUI.VerticalSlider(new Rect(210, 170, 100, 30), vSliderValue, 10.0F, 0.0F);
hSValue = GUI.HorizontalScrollbar(new Rect(210, 210, 100, 30), hSValue, 1.0F, 0.0F, 10.0F);
vSValue = GUI.VerticalScrollbar(new Rect(210, 230, 100, 30), vSValue, 1.0F, 10.0F, 0.0F);10、GUI.GetNameOfFocusedControl
Get the name of the currently focused control , If there is no focus or control name, an empty string is returned .
11、GUI.Window、 GUI.FocusWindow、GUI.DragWindow
GUI.BringWindowToBack、GUI.BringWindowToFront
//GUI.depth、GUI.BringWindowToBack、GUI.BringWindowToFront Can change the level of the window
//GUI.BringWindowToBack GUI.BringWindowToFront
private Rect windowRect = new Rect(20, 20, 120, 120);
private Rect windowRect2 = new Rect(80, 20, 120, 120);
private Rect windowRect3 = new Rect(150, 20, 120, 120);
// GUI.depth
int guiDepth1 = 0;
int guiDepth2 = 0;
//
string m_focusedControlName = "";
void OnGUI()
{
windowRect = GUI.Window(0, windowRect, DoMyWindow1, " The first window ");
windowRect2 = GUI.Window(1, windowRect2, DoMyWindow2, " The second window ");
windowRect3 = GUI.Window(2, windowRect3, DoMyWindow3, " Third window ");
}
void DoMyWindow1(int windowID)
{
// GUI.depth = guiDepth1;
if (GUI.Button(new Rect(10, 20, 100, 20), "Window1"))
{
//GUI.BringWindowToBack(1);// Window id by 1 The window is set to the last
//guiDepth1 = 1;
//guiDepth2 = 0;
//GUI.BringWindowToFront(1);// Window id by 1 The window is set to the front
GUI.FocusWindow(1); // Focus on id by 1 The window of
}
//DragWindow Windows that can be dragged
GUI.DragWindow(new Rect(0, 0, 10000, 20));
}
void DoMyWindow2(int windowID)
{
//GUI.depth = guiDepth2;
if (GUI.Button(new Rect(10, 20, 100, 20), "Window2"))
{
//GUI.BringWindowToBack(2);
//guiDepth1 = 0;
//guiDepth2 = 1;
GUI.BringWindowToFront(2);
}
GUI.DragWindow(new Rect(0, 0, 10000, 20));
}
void DoMyWindow3(int windowID)
{
// GUI.depth = guiDepth2;
if (GUI.Button(new Rect(10, 20, 100, 20), "Window3"))
{
//GUI.BringWindowToBack(0);
//guiDepth1 = 0;
//guiDepth2 = 1;
GUI.BringWindowToFront(0);
}
GUI.DragWindow(new Rect(0, 0, 10000, 20));
}
边栏推荐
- 杰理之wif 干扰蓝牙【篇】
- fatal: unsafe repository (‘/home/anji/gopath/src/gateway‘ is owned by someone else)
- Ugui uses tips (VI) unity to realize vertical line display of string
- 搭建学习环境
- 【C语言】关于scanf()与scanf_s()的一些问题
- After importing resources, unity also manually modifies the properties of resources? This code can save you a lot of time: assetpostprocessor
- [unity Editor Extension Foundation], editorguilayout (I)
- Research on personalized product search
- 杰理之SPI1外挂FLASH录音修改【篇】
- Many benefits of SEO optimization are directly related to traffic
猜你喜欢

洛谷_P1303 A*B Problem_高精度计算

Leetcode 705. 设计哈希集合

Build your own website (18)

RemoteViews布局和类型限制源码分析

websocket 1 分钟自动断开连接

Given two points and a point with a middle scale, find the coordinates of the point

Unity Editor Extension Foundation, editorguilayout (III)

In less than an hour, apple destroyed 15 startups

Function and principle of remoteviews

【Unity编辑器扩展基础】、EditorGUILayout (三)
随机推荐
MapReduce项目案例1
PrecomputedTextCompat用法及原理
Daily practice of C language - day 3: calculate the number of occurrences of sub strings of strings
Truly understand triode beginner level chapter (Classic) "suggestions collection"
自定义标题栏View
Research on personalized product search
杰理之wif 干扰蓝牙【篇】
Is there a threshold for opening futures accounts? How to open futures accounts safely on the Internet
js 期约与异步函数 Promise
Build your own website (18)
What are the common modes of financial products in 2022?
Asynctask experience summary
【Unity编辑器扩展实践】、利用txt模板动态生成UI代码
双缓冲绘图
运维思考 | 你知道CMDB与监控是什么关系吗?
UGUI强制刷新Layout(布局)组件
【vi/vim】基本使用及命令汇总
Zero basic C language (I)
【C语言】判断三角形
【Unity编辑器扩展基础】、GUI