unity 自动排版(Horizontal Layout Group)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了unity 自动排版(Horizontal Layout Group)相关的知识,希望对你有一定的参考价值。

参考技术A “水平布局组”组件将其子布局元素并排放置。它们的宽度由各自的最小,首选和灵活的宽度决定,具体取决于以下模型:

所有子布局元素的最小宽度被添加在一起,并且它们之间的间距也被添加。结果是水平布局组的最小宽度。
所有子布局元素的首选宽度被添加在一起,并且它们之间的间距也被添加。结果是“水平布局组”的首选宽度。
如果水平布局组的最小宽度或更小,则所有子布局元素也将具有其最小宽度。
“水平布局”组越接近其首选宽度,每个子布局元素也将越接近其首选宽度。
如果“水平布局组”宽于其首选宽度,它将根据子布局元素各自的灵活宽度按比例分配额外的可用空间。

Unity学习笔记 --- Unity的界面排版:初识GUI

GUI和GUILayout是Unity提供的UIKit。在使用GUI的Controls时都要求设置Rect參数。没办法做到自己主动排版,给适配带来难度。而GUILayout的设计就是为了弥补这个缺陷,GUILayout是在GUI的基础之上复合了一套Layout的排版逻辑。


GUI

class in UnityEngine

Description

The GUI class is the interface for Unity‘s GUI with manual positioning.


See Also: GUI tutorial.

Static Variables

backgroundColorGlobal tinting color for all background elements rendered by the GUI.
changedReturns true if any controls changed the value of the input data.
colorGlobal tinting color for the GUI.
contentColorTinting color for all text rendered by the GUI.
depthThe sorting depth of the currently executing GUI behaviour.
enabledIs the GUI enabled?
matrixThe GUI transform matrix.
skinThe global skin to use.
tooltipThe tooltip of the control the mouse is currently over, or which has keyboard focus. (Read Only).

Static Functions

BeginGroupBegin a group. Must be matched with a call to EndGroup.
BeginScrollViewBegin a scrolling view inside your GUI.
BoxMake a graphical box.
BringWindowToBackBring a specific window to back of the floating windows.
BringWindowToFrontBring a specific window to front of the floating windows.
ButtonMake a single press button. The user clicks them and something happens immediately.
DragWindowMake a window draggable.
DrawTextureDraw a texture within a rectangle.
DrawTextureWithTexCoordsDraw a texture within a rectangle with the given texture coordinates. Use this function for clipping or tiling the image within the given rectangle.
EndGroupEnd a group.
EndScrollViewEnds a scrollview started with a call to BeginScrollView.
FocusControlMove keyboard focus to a named control.
FocusWindowMake a window become the active window.
GetNameOfFocusedControlGet the name of named control that has focus.
HorizontalScrollbarMake a horizontal scrollbar. Scrollbars are what you use to scroll through a document. Most likely, you want to use scrollViews instead.
HorizontalSliderA horizontal slider the user can drag to change a value between a min and a max.
LabelMake a text or texture label on screen.
ModalWindowShow a Modal Window.
PasswordFieldMake a text field where the user can enter a password.
RepeatButtonMake a button that is active as long as the user holds it down.
ScrollToScrolls all enclosing scrollviews so they try to make position visible.
SelectionGridMake a grid of buttons.
SetNextControlNameSet the name of the next control.
TextAreaMake a Multi-line text area where the user can edit a string.
TextFieldMake a single-line text field where the user can edit a string.
ToggleMake an on/off toggle button.
ToolbarMake a toolbar.
UnfocusWindowRemove focus from all windows.
VerticalScrollbarMake a vertical scrollbar. Scrollbars are what you use to scroll through a document. Most likely, you want to use scrollViews instead.
VerticalSliderA vertical slider the user can drag to change a value between a min and a max.
WindowMake a popup window.

Delegates

WindowFunctionCallback to draw GUI within a window (used with GUI.Window).

以上是关于unity 自动排版(Horizontal Layout Group)的主要内容,如果未能解决你的问题,请参考以下文章

Unity学习笔记 --- Unity的界面排版:初识GUI

一个Unity富文本插件的实现思路

unity3d C#写发射子弹的程序怎么写

Horizontal Pod Autoscaler(Pod水平自动伸缩)

自动扩容之Horizontal Pod Autoscaling(HPA)

1.5 Unity