Ngui Structure UI Root (2D) for creating a UI UI object with a camera parameter of simple 2D

Source: Internet
Author: User

Ngui Structure UI Root (2D) for creating a UI UI object with a camera parameter of simple 2D

UseNGUIcreated byCameraparameter isSimple 2Dof theUI, it will spawn in the game scene.1a name ofUI Root (2D)Object , and this object also contains the3a different object:Camera,Anchorand thePanel,1-4is shown. This section describes each of these4a Game Object This article is selected from Ngui from the beginning to the actual combat .

Figure 1-4 in the Hierarchy view to view the newly created UI Game Objects

1.4.1 UI Root (2D)

this game object will be responsible for controlling UI the size of the control. Select the UI Root (2D) object in the Hierarchy View and view the components on this game object in the Inspector view. as shown in 1-5.

Figure 1-5 in the Inspector View View UI Root (2D) The components of the object

transform component in unity The game object is very common, or all the game objects have this component, it is not usually introduced. and uiroot (Script) This article is selected from ngui from beginner to actual combat :

qscaling Style : can be used to modify ui zoom style of the control.

Tip: This property has 3 Optional Parameters: Pixelperfect , fixedsize and the Fixedsizeonmobiles .

2 Pixelperfect, will ensure thatUIcontrol always retains the specified pixel size, regardless of the game resolution. For example, specify a pixel size of -x $, then the game in thex -the resolution, thisUIthe control will be very large, and the1920x1080x thethe resolution, thisUIThe control will be very small.

2fixedsize the Span style= "line-height:1.5" >ui control regardless of the game resolution, Always keep the specified size ratio in the game view. That is ui The control is scaled proportionally as the game view is scaled.

2fixedsizeonmobiles You will ensure that the ui controls, Keep the specified size ratio while on the mobile device, and keep the specified pixel size when on other devices.

qmanual height : when ui control's zoom style is fixedsize ui Whether the control requires proportional scaling. For example, when the height of the game view is greater than the value set by this property, ui controls are scaled proportionally, and when the height is less than this value, the ui

hint: ui When the control is scaled, the control's aspect ratio is constant.

qminimum height : when ui control's zoom style is pixelperfect ui The control will be actively scaled down;

qmaximum height : when ui control's zoom style is pixelperfect ui The control will be actively scaled up;

Tip: The resolution scale of the game view is varied and UI The control only determines whether the control is scaled based on its height, so it is possible to cause a different game resolution scale to appear UI control may be "clipped" by the view. In order to cope with this situation, it is recommended that readers use two methods to avoid it.

method One: the UI control is set to square, i.e. UI the width and height of the control are the same;

method Two: Specify the resolution scale of the game for the game view. The specified method is to Click edit| in Unity Project settings| The Player command pops up A dialog boxnamed Playersettings, as shown in1-6 .

figure Span style= "line-height:1.5" >1-6  playersettings dialog box

Expand playersettings in the dialog box Resolution and Presentation Property Group, set the supported Aspect Ratios Properties, 1-7 is shown.

Figure 1-7 Resolution and Presentation attribute Group

Unitythe default supported game views are a number of different rates, such as4:3, -:Tenand so on, if you want the game to be a separate rate4:3To cancel the check of other resolutions This article is selected from Ngui from start to combat .


Ngui Structure UI Root (2D) for creating a UI UI object with a camera parameter of simple 2D

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.