当前位置:网站首页>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));
}
边栏推荐
- Truly understand triode beginner level chapter (Classic) "suggestions collection"
- Sha256 encryption tool class
- Ugui force refresh of layout components
- Research on personalized product search
- .NET混合开发解决方案24 WebView2对比CefSharp的超强优势
- 最新汇总!30省份公布2022高考分数线
- 【C语言】如何很好的实现复数类型
- Software test interview classic + 1000 high-frequency real questions, and the hit rate of big companies is 80%
- What is the difference between internal oscillator, passive crystal oscillator and active crystal oscillator?
- Is tongdaxin stock software reliable? Is it safe to trade stocks on it?
猜你喜欢

Unity Editor Extension Foundation, editorguilayout (II)

什么是数据合规?怎样做到数据合规?

pwn入门(1)二进制基础

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

Leetcode 705. 设计哈希集合

Ugui uses tips (VI) unity to realize vertical line display of string
Using MySQL database in the express framework of node

Source code analysis of ArrayList

EMC RS485 interface EMC circuit design scheme

Deep learning has a new pit! The University of Sydney proposed a new cross modal task, using text to guide image matting
随机推荐
RemoteViews布局和类型限制源码分析
杰理之wif 干扰蓝牙【篇】
Cohere, a large model company, completed the round B financing of US $125million
PrecomputedTextCompat用法及原理
AsyncTask经验小结
[vi/vim] basic usage and command summary
杰理之wif 干扰蓝牙【篇】
什么是数据合规?怎样做到数据合规?
【C语言】判断三角形
Open3d manual clipping point cloud
C语言 sprintf函数使用详解
Deep learning has a new pit! The University of Sydney proposed a new cross modal task, using text to guide image matting
Two writing methods of JNI function
Function and principle of remoteviews
【C语言】关于scanf()与scanf_s()的一些问题
【Unity编辑器扩展实践】、查找所有引用该图片的预制体
AcWing 608. Poor (implemented in C language)
已知两个点和中间一个比例的点,求该点坐标
[C language] about scanf() and scanf_ Some problems of s()
【C语言】文件读写函数使用