Welcome to Unity Learning,Unity training ,UnityEnterprise TrainingEducation Area, there are manyu3d Resources,u3d Training Video,u3d Tutorials,U3d Frequently Asked questions,u3d Project Source code, the "Dog Planing Learning Network" Unity's Ultimate Academy, dedicated to building the industry unity3d Training , learning the first brand.
Ngui Study Notes
I. Direct use of Ngui
1. Attach a Collider: For some objects Ngui to add Collider, if the interface is done with Ngui, only add this way. (Note: Add invalid with component).
2. Attach an Anchor: Indicates that an uianchor script has been added to the object to avoid pixel offset issues
3. Attach Uistretch: Indicates that an uistretch script has been added to the object to provide the zoom function
4. Make Pixel Perfect: Indicates that the transform size is automatically adjusted for you
5. Create a Panel: Represents the creation of a polygon, equivalent to a container, where the Button,label,checkbox controls are all contained within the Panel
6. Create a widget: Indicates creating a widget, such as Button,label,sprite, etc.
7. Create a new UI: represents the creation of a fresh UI interface
8. Font Maker: Creating fonts
9. Atlas Maker: Creating a set of images
two. Component/ngui/examples
1.PanWithMouse, which means that the object you give will move according to the mouse's transformation (floating feeling)
2.LookAtTarget, indicating that the object is facing your target object
3.LoadLevelOnClick, the click button to load to another scene, write on levelname you want to load the scene name can be
4.Spin, swivel
5.SpinWithMouse, follow the mouse rotation
6.TypewriterEffect, for labels, typing style
7.Chat input, submit the contents of the input box to the text box
three. Component/ngui/interaction
1.Button:
A:uibutton: Mouse over button to change the color of the target object
B:uibuttonscale: Mouse over button, target object becomes larger or smaller, adjust the proportion of x, Y, z in hover
C:uibuttonoffset: Mouse on the button, the target object reposition position
D:uibuttonsound: Mouse click button to make a sound
E:uibuttonactivate: When the mouse button is clicked, the target object is disabled to the enabled state (triggering the object)
F:uibuttoncolor: The target object becomes color when the mouse moves to the button
G:uibuttonrotation: When the mouse moves to the button, the target object rotates a certain degree, in the hover to adjust the degree of x, Y, z rotation
H:uibuttontween: After the mouse clicks the button, the target object produces the transformation, must add to the target object the Tween component inside transformation (example: Transform transformation, Position transformation, the Alpha transformation and so on), and starts to enable the object the transformation, Because this transformation is generated after a mouse click, or it will start to run the game, it will produce a transformation
I:uibuttonplayanimation: The target animation plays when the mouse button is clicked (the target object must be added animation)
J:uibutton message: To pass messages, write a public function that tells you what to pass the message to, put the script on your target object, and then write the name of the function you want to pass the message to
2.CheckBox:
A:uicheckbox: For selection and cancellation of multi-selection boxes
B:uicheckboxcontrolledobject: If you cancel the selection of this marquee, the target object and all sub-objects are all disabled
C:uicheckboxcontrolledcomponent: If you add this script to the checkbox, the target of this script will be displayed if the multi-select button is selected, and the target of this script will be hidden if the multiple selection button is not selected
3.Drag:
A:uidragcamera: Add the component to an object and then add the Uidraggablecamera component to the camera, indicating that it is allowed to be dragged, and then place the camera under the Uidragcamera target camera and drag the object The camera's position will change.
B:uidraggablecamera: Indicates that the camera is allowed to be dragged
C:uidraggablepanel: Indicates that the face (container) is allowed to be dragged
D:uidragobject: Drag the object, the allowed drag of the object will be dragged, this allowed to drag the object must be placed under the target object
E:uidragpanelcontents: Indicates that all components of the polygon are also allowed to be dragged
4. Other
A:uiforward events: Represents an event to be forwarded from an object to another (Learn more)
B:uigrid: To add a mesh for the object, which can contain a number of items, can be selected vertically or horizontally in the Arrangemwnt, cell width and cell height represent the width and height of each cell
C:uicenteronchild: Often used in drag-and-drop events, add a Uidraggablepanel script to the panel, and then add Uidragobject or Uidragpanelcontents to the object you want to drag, Then add Uicenteronchild to the grid root, regardless of how you drag the object inside the container, and the grid remains centered horizontally or vertically
D:uiinputvalidator: For input box, after adding this script to the input box, there are a number of options in logic, none means no validation, no characters can be entered (except Chinese), and integer indicates that only integers can be entered. Can not enter English and a variety of special characters, double means only floating point number can be entered, alphanumeric indicates what English and numbers and special characters are allowed to enter, username that can be entered in English, numbers, some special characters (except the decimal point), Name indicates that only English and special characters (except decimal points) can be entered
E:uipanelalpha: Used for any control, add this script to the object, in Alpha can adjust the parameters, 0 is full transparent, 0-1 is more opaque, more than 1 of the numbers indicate completely opaque
F:uipopuplist: This script is added to the drop-down list box (popuplist) When you create the Popuplist control through Ngui, and in the options you can add a drop-down list box subkey
G:uiscrollbar: For scroll bars, value for the position of the current scrollbar, size for one element of a scrollbar, alpha for scrollbar transparency, direction to select whether the scrollbar is vertical or horizontal
H:uislider: Used for sliding box, value indicates the proportion of this slider is filled, direction indicates whether the sliding frame is vertical or horizontal
I:uisoundvolume: For use in slider controls
J:uitable: Add a table, columns represents the number of columns in this table, and down means that the controls in a column are arranged from top to bottom, and up means that the controls within a column are arranged from the top down, padding represents the distance of each control
four. Component/ngui/tween
1.Spring Position: Represents the position of the transformed object, target is the destination, and the object moves from the start position to the target position.
2.Tween Alpha: Represents the transparency of an object from one value to another, from a value that begins, to a value after
3.Tween color: Represents the color of an object from one value to another, from the start color, to the color after
4.Tween Position: Represents the coordinates of an object from one position to another, from the position of the beginning, to the position after which it is represented.
5.Tween Rotation: Represents the transformation of an object from one angle to another, from the angle of the beginning, to the angle after which it is expressed.
6.Tween Scale: A transformation that represents the size of an object from one value to another, from the size of the start, to the size after which it is represented
7.Tween Transform: Represents the Transform transformation of an object, from the position of the object at the beginning, to the position of the object after
Five. Creating a control ngui/create a Widget
A: Create label: Label
B: Create a dropdown box: Popup list
C: Create a progress bar: Progress Bar
D: Create Slide bar: Slider
E: Create input box: input
F: Create scroll bar: Scroll bar
G: Create buttons: button
H: Create Multi-box: checkbox
I: Create a Sprite: A sprite is a small picture from a large set of graphs
Sprite: A general Sprite
Sliced Sprite: A sprite with a fixed border
Tiled Sprite: Scaling a Sprite that repeats the entire area (for example, barbed wire)
Filled Sprite: Each will have a separate parameter to control what is visible, often used for scroll bars and progress bars
J: Create input box: input
Six. Ngui Event System
The Ngui event function can be written to a Ngui control script, or a script with a Collider object (rendered by a camera with a uicamera component).
Common events:
void Onhover (bool isover): Triggered when the mouse hovers or moves out. Pass in true when hovering, passing false when moving out.
void Onpress (bool Isdown):: Triggered when the mouse or touch is pressed or released, passed in true when pressed, and false when released.
void OnClick (): triggered when the mouse or touch is clicked (pressed and released).
void OnDoubleClick (): Triggered when double-click (double-click time interval is less than 0.25 seconds).
void OnSelect (bool selected): Similar to a click, the difference is that the OnSelect event is no longer triggered after the check is selected, unless other controls are selected during the period.
void Ondrag (Vector2 delta): triggered when the mouse or touch is pressed and moved. The delta is the incoming displacement.
void Oninput (string text): Used only for input controls, fires every time the input is completed, text passes in the information entered in this input, not text information in the input control.
void Ontooltip (BOOL show): Triggers when the mouse hovers over a period of time or moves, passes in true when hovering, and passes in false when it moves away.
void Onscroll (float delta): triggered when the middle mouse button is scrolled, Delta is the incoming scroll increment.
Seven. Common related variables
Uicamera.currenttouchid Uicamera class variable, used to distinguish the mouse pressed keys, 1 is left, 2 is right, 3 is the middle key
Uicamera.lasthit Uicamera class variable, raycasthit type. Used to get the object being triggered.
Uicamera.lasttouchposition Uicamera class variable, used to get the position of the mouse or touch.
For more information, please visit the "Dog Planing Learning Network" Unity Ultimate Academy Http://edu.gopedu.com
Statement: This document comes from the "Dog Planing Learning Network" Community-unity Extreme College, is a self-published Unity3d study articles, if anything violates your relevant interests, please communicate with the official, we will deal with the real-time.
Ngui Study Notes Summary