In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to call the GUI control in Unity, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can get something.
GUI controls:
1. Initialize in Start and adjust in OnGUI.
two。 Only public variables appear in the Inspector panel.
Initialization and processing of the 3.GUI control is done within the OnGUI.
The Chinese of 4.JavaScript can be displayed as UTF-8 code, and the Chinese of CSharp as UTF-16 code can be displayed.
Basic information:
Screen width and height: Screen.width Screen.height
Picture width and height: img.width img.height
One tag Label
GUI.Label (Rect (xonomery widthdepartment height),)
Two-button Button
Var buttonTexture: Texture2D
GUI.Button (Rect (xonomy department width height), buttonTexture)
Set text color: GUI.color = Color.green
Set the background color: GUI.backgroundColor = Color.red
Three input boxes TextField
Message = GUI.TextField (Rect (xonomer yjournal widthdepartment height), message,size)
Message = GUI.PasswordField (Rect, message, * "[0], size)
The return value type is String.
Four check boxes and tabs selectToggle and Toolbar
Var barResource: String [] = ["bar1", "bar2", "bar3",...]
Var select: int
Var state: boolean
Select = GUI.Toolbar (Rect,default,barResource); / / the second parameter is on the tag by default, followed by a list of names
There are several tags for every element.
Get the tag page: select = GUI.Toolbar (...)
Get the check box: state = GUI.Toggle (Rect,state,)
Five slider Slider
Var now_value: int = 0
Now_value = GUI.VerticalSlider (Rect,now_value,endvalue,startvalue)
Six scroll bars ScrollView
Defines where the Vector2 variable stores the horizontal and vertical scroll bars.
Var scrollPosition: Vector2
ScrollPosition [0] =
ScrollPosition [1] =
ScrollPosition = GUI.BeginScrollView (
, true,true)
/ / the last two parameters indicate whether to display intelligently, that is, if the scroll bar should not be displayed, it will not be displayed.
Seven groups Group
The relative coordinates are used in the group, and the objects in the group move uniformly.
GUI.BeginGroup (new Rect (xtropy _ width _ height))
/ / add members of the group here
GUI.EndGroup ()
Eight-window Window
GUI.Window (ID,Rect,window_function,name)
Use: Debug.log (); to output a string in the bottom message panel.
Nine style sheets GUISkin
Apply the stylesheet using: GUI.skin = mySkin
Ten layout GUILayout
GUILayout automatically calculates the display area.
Most of the space can be drawn from the GUI class to the GUILayout class.
GUILayout can also set the width and height of the layout. Width and Height methods are used.
Use: BeginHorizontal () and EndHorizontal () methods
The default is vertical layout, so multiple layouts are arranged vertically by default.
And: BeginVertical () and EndVertical () methods
Horizontal and vertical layouts can be set, and can be used in nesting.
Eleven linked list ArrayList () class
Use: var winArrayList = new Arraylist (); declare
The Add method adds a node, and the RemoveAt method deletes a node.
For the use of windows:
WinArrayList.Add (Rect)
WinArrayList [I] = GUILayout.Window (...)
WinArrayList.RemoveAt (windowID)
One or two still pictures DrawTexture
Var pic: Texture2D
GUI.DrawTexture (Rect,pic)
The practical class methods width and height can obtain the actual width and height of the image, such as pic.width
Thirteen 2D animation
Use an array of type Object [] to store animation frames
How to load animation frames:
Private var animation: Object []
Animation = Resources.LoadAll (""); / / load all pictures under / Resouurces//
The GUI.DrawTexture method is used to draw animation.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.