Unity Individual Component Parameters Summary

Source: Internet
Author: User

Today in the bull education to learn the Ngui of the course below to everyone summed up a little bit of knowledge, hope to help everyone
Uicamera-can be added to any camera that contains the event system.
Uicamera is an important part of every UI. It is responsible for sending all Ngui activities in the camera. If there is only one camera in the scene, make sure it is accompanied by a Uicamera script. If you have more than one camera, Make sure that the camera that is used to render the UI at least has a uicamera script. When you place this script on the main camera, all the events in the game scene will have OnClick, Onhover, Ondrag, and so on.


Parameters
Tooltip Delay: Sets how many seconds to hover with the object to perform the Ontooltip event.
If you use the orthographic projection camera, it is recommended that the size of the camera be set to half the current resolution height. For example, for ipad screen 1024x768 resolution, set size to 384. Another way is to keep size 1, The root of the scaling UI is the reciprocal of this value, such as getting the perfect size on the ipad you need to set the root zoom to 1/384 or 0.002604167. The second method is easier to implement, but the object is smaller than other objects in the scene view.
If you still do not know how to set the size of the orthogonal camera, then try to look at the following figure.


Uiatlas-defining the sprite's texture map
Uiatlas is a container that contains the coordinate information of a bunch of sprites. If you're not familiar with the concept. You can think of this: using a large map with a lot of small stickers is more efficient than using several small maps. Small maps in large maps are called sprites (sprites), and large textures become atlas (Atlas).
Before you use Ngui, you need to create an atlas (or use an existing one). You can learn about Atlas from here. Of course you can use uitexture directly, but it's not going to solve all the problems.


Material: Is the material that describes the drawing of this atlas. It is usually recommended to use a unlit shader, for example. Unlit–transparent colored for Ngui.
TP import: Used to import sprites exported from Texturepacker. Just drag the output TXT file and all the sprites.
Coordinates: This allows you to switch from a pixel-based coordinate system to a UV-based coordinate system. It's usually made in a pixel coordinate system, but if you need to readjust the texture, switch to texture coordinates first.
New Sprite: Allows the currently selected sprite to create a fresh sprite for the template.
Delete: Deletes the selected sprite.
Sprite: You can select all the sprites you are using from the drop-down list.
Edit Name: Rename the sprite.
Outer Rect: Sets the outer border of the sprite.
Inner Rect sets the inner border of the sprite, and if you do not use Uislicedsprite, you can skip this setting.
Padding: Adjusting the offset of the sprite
Correction: The coordinates of the base correction sprite use perfect integer pixels.
Show: Check the sprite's position in the gallery.


Tips
You can organize sprites into groups to create multiple collections. As long as the Atlas shares the same material, the control will still use very little drawcall.
For best results, it is recommended to set the wrap mode of the texture to "Clamp" and the format to "Truecolor".
It's a good way to make a similar texture into an atlas, but try to minimize the number of simultaneous atlas.
If you are using the texture Packer tool to create the atlas, select Unity3d in the output settings.


If you are using Photoshop to create an atlas, you can find the location and size of the sprite by selecting the tool with the Info Panel panel.


uifont-Font Atlas
Uifont can set the font data and materials used by the UI. You can use the free bmfont, or use a more professional glyph Designer. Usually only once, save as a preset, as the font used for the new label. Parameters:


Import Font: The FNT (renamed TXT) data used to import glyph Designer. or Bmfont output.
Uiatlas: Used to set the atlas in which the font texture is located, depending on whether the Uiatlas is selected, you will see the option
If Uiatlas has been specified, you can choose the sprite that uses the font.
If you do not specify Uiatlas, you can choose the material to use to draw the font. In Ngui, shaders, such as unlit–transparent colored, are typically used in the "unlit" category.
You can adjust the pixel rectangle within the texture of the font.
Quickly corrects perfect pixel coordinates, rounded to the nearest pixel value.
Spacing: You can adjust the spacing between characters.
Show: Check the position of the font in the texture map.


Tips
For best results, it is recommended to set the wrap mode of the texture to "Clamp" and the format to "Truecolor".
You can combine multiple fonts into one atlas. This way the entire UI uses these fonts and still maintains a drawcall.
You can add an effect such as bevel, shadow, stroke, and so on, just make sure you have enough margin and spacing before you bmfont export.
uisprite-draw an elf from a set of figures
Uisprite is the second infrequently used plugin (the first is uitexture), and its only purpose is to draw part of the Atlas.


Parameters
Transform: is an important component, and each control can be adjusted for position and size by Transform. It also affects "make Pixel-perfect". You can choose between it and Uicamera to make the "perfect pixel" adjustment.
Uiatlas: Used to specify which atlas to use. Drag or press the left button to select the most recently used atlas.
Sprite: Select the sprite used in the set. After selecting the good elf. Click "Make Pixel-perfect" to automatically adjust the transform size for you.
Depth is to avoid using Unity's Z-sort (inefficient), and if you want to rotate the UI window. Simply sorting by adjusting the z-axis of each control's transform is not a good idea. So use this depth to sort.
Color Tint: Used to adjust the hue.
Make Pixel-perfect: Lets you quickly adjust the size of the control to the actual pixel size.
Pivot: Select the coordinate origin position of the part.
Preview: Previews the texture of the sprite.


Tips:
If you see two controls flashing, meaning that you set the same depth cause overlap, you have to adjust the different depths so that they do not overlap.
Do not mix multiple controls together, otherwise it will affect the function of perfect pixels. Be careful to keep creating new child objects when adding new controls.
You can also move the combo control after using the perfect pixel button.
label-draws a text label with the specified font
Uilabel is used to display text. Support multiple lines, just use "\ n" to wrap. Allow [RrGgBb] to create color text


Parameters:
Transform: is an important component, and each control can be adjusted for position and size by Transform. It also affects "make Pixel-perfect". You can choose between it and Uicamera to make the "perfect pixel" adjustment.
Uifont: You can choose which font to use for this label. You can drag the preset or press the button to select the most recently used font.
You can use "\ n" to determine whether a label is a multiline or a single line, you can also use a 16-color value to define color text, starting with [RrGgBb] and ending with [-]. As in "Hello [ff0000]world[-]!", the final result is that world is red text.
Line width: Used to specify the maximum width of the lines of text, and if it is a single line of text, it will be cut out. If multiline text is wrapped, it wraps automatically according to the width.
Multi-line: When the item is selected, the label will wrap automatically when it reaches the maximum width.
Password: The character is automatically converted to an asterisk when checked.
Encoding: When checked, special character processing is turned off, which is generally used for input boxes.
Depth: The hierarchy of the change-edge label control.
Color Tint: Changes the main tone of the text.
Make Pixel-perfect: Lets you quickly adjust the size of the control to the actual pixel size.
Pivot: Select the coordinate origin position of the part.
Preview: Previews the texture of the sprite.


Tips:
If you see the text flashing or seeing it being overwritten by another control. Then adjust its depth.
If you encounter complex strings (such as italic, punctuation, and parentheses) you need to increase the line width to avoid extra-wide.
with "\ n" and color, only one label can do the following effect.


uipanel-groups controls for managing and optimizing Drawcalls
The UIPanel is used to create the actual geometry. You do not have to add uipanel specifically, as long as you create a control, it is automatically added. You can create multiple panel for multiple menus.


Parameters:
Normals: Displays normals to check whether the UI is correct or negative.
Gizmos: Used to display geometry, available for selection.
Debug: Check the geometry of the scene view with debugging, if you turn this on. You should cancel the gizmos option above.
Widgets: Displays the number of controls on this panel.
Draw Calls: You can see how many drawcall are used, the lower the better.
Clipping: You can select the part you want to display, which is not trimmed by default. Is trimmed with a shader, and if this option is turned on, Ngui automatically switches to the shader with crop properties.
If the crop is on. You can set the Trim box by using center and size. Units are pixels.
If you select soften edge trimming, there will be a softening edge of 40 pixels to handle the softening effect.
Material: Read-only, you can see how many materials the panel uses. A material will occupy a drawcall.


Tips:
By default, if there is no uipanel, it is created by the most-rooted control and acts as its parent. And it's better to let you use a parent object for multiple controls for easy administration.
If there are no controls under panels. You can safely delete this panel.
If you delete the panels of a stored control, it and the controls underneath it will disappear, but when you play, all the controls will reappear, because a uipanel is created automatically.
When there is no change, the geometry does not rebuild, which means that if there is a completely static UI, no frames will be updated to update the geometry, instead it will be reused to improve performance.
The uianchor-allows the control to automatically fit the screen size, filling the UI with full screen and maintaining true pixel size.
The Uianchor has multiple uses, including relative positioning of the screen at multiple resolutions.
If you put it on the root of the 2D UI, it will do the perfect pixel processing automatically.
If you use it for an object, it will position the helper on the screen, such as the side or corner.
For example, on an elf, it can be used to automatically fill the screen with sprites, such as a background.


Parameters:
The HUD camera is used to draw the object's cameras, which are usually automatically selected.
Side: Sets the anchor point, with 4 sides, 4 corners, and a center for selection.
Half Pixel Offset: A bug that lets the control have a half-pixel offset to avoid DirectX 9 on a Windows machine.
Stretch to fill: Scales the fill, which is usually used when the background is done.
Depth Offset: Adjusts the depth of the calculation points when using a perspective camera.


Tips:
If the object has uianchor this script, its own transform will not accept your changes because it is controlled by this script. If you want to add a displacement based on this anchor point, you can add a sub-object. For example, you want a control that is always at the screen offset (100,100), You should make such a structure in the hierarchy panel. Ui->anchor->offset->widget.
The Uianchor is also available for non-orthogonal cameras.
If the Uiorthocamera is attached to the camera, the interface created with Uianchor will be fixed in size and position, no matter how big your screen size is.
Events-ngui Powerful Event System
uievents-Event System
You can add the following method script to the control or the game object with the collision box, of course, can also be given to the camera, but need to have the camera Uicamera script:
void Onhover (bool isover): Returns a Boolean value when the mouse moves out or hovers over a collider. There is no effect on touch devices.
void Onpress (bool Isdown): A Boolean value is returned when the mouse or touch to the collider occurs.
void OnSelect (bool selected): This boolean value is returned when the mouse or touch is released after the onpress occurs.
void OnClick (): Is the same as the onselect, which is triggered when a hit or touch collider and no drag occurs.
void Ondrag (Vector2 delta): triggered when moving the mouse or when the shift exceeds a specific threshold when the touch is pressed.
void OnDrop (Gameobject drag): Triggers when the mouse or touch is released from different collider wounds that occur Ondrag. The passed parameter is the game object that produces the Ondrag.
void Oninput (string text): Triggers input on the same collider after a onselect occurs. Generally only uiinput use it.
void Ontooltip (BOOL show): Triggers the command when the mouse hovers over tooltipdelay time. Touching the device does not work.
You can use Uicamera.lastcamera to find out who sent the event, available Uicamera.lasthit get who accepts this event, and use Uicamera.lasttouchposition to get a touch or screen position
When the following script assigns a collider, clicking on the collider will output HelloWorld.

Unity Individual Component Parameters Summary

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.