a few days ago with Ngui made a form (effect as shown), now the process to share with you, in particular, referring to Ngui's seventh demo produced, we can take a closer look at example 7-scroll View (Panel).
1. In general, the Scroll View+scroll bar is used to make, item object I use button, this is to be able to click or more convenient to deal with some other things. As for the use of Ngui here is not in detail, we can find some of the online Ngui tutorial documents to see.
2. Click on the object to see the color change of the phenomenon, here is a direct change of the value of the UIButton defaultcolor, cancel the selected state is to restore the default color value, directly call Resetdefaultcolor ();
- //set selected object default color change
- _secondclickobject.getcomponent<uibutton > (). defaultcolor = new Color (21f/255f, 122f/255f, 2f/255f, 1f);
- < BR style= "" >
- //Restore First selected object default color
- _firstClickObject.GetComponent<UIButton> (). Resetdefaultcolor ();
Copy Code
[Color=rgb (Wuyi, 102, 153)!important] copy code
3. Double-click the login function implementation, since Ngui has encapsulated the double-click event, so we call directly on the line OnDoubleClick ();"Dog planing Learning Net"
4. The exchange between the first-click object and the second-click object is a declaration of an instance of the two-click object, enabling a return-to-back switch between two different objects.
- <summary>
- Judging Click Object
- </summary>
- <param name= "Item" > Selected Item Object </param>
- public void SelectItem (Gameobject item)
- {
- Currently selected item object
- GAMEDATA.CURRGAMEOBEJCT = Item;
- Judge two times the selected object, the first selected, the second selected
- if (_firstclickobject = = null)
- {
- _firstclickobject = Item;
- Sets the default color change for the selected object
- _firstclickobject.getcomponent<uibutton> (). DefaultColor = new Color (21f/255f, 122f/255f, 2f/255f, 1f);
- if (_secondclickobject! = null)
- {
- Restores the default color of the second selected object
- _secondclickobject.getcomponent<uibutton> (). Resetdefaultcolor ();
- _secondclickobject = null;
- }
- Return
- }
- Else
- {
- _secondclickobject = Item;
- Sets the default color change for the selected object
- _secondclickobject.getcomponent<uibutton> (). DefaultColor = new Color (21f/255f, 122f/255f, 2f/255f, 1f);
- Restores the default color of the first selected object
- _firstclickobject.getcomponent<uibutton> (). Resetdefaultcolor ();
- _firstclickobject = null;
- }
- }
Copy Code
5. Add the interface (as shown)
6. Modify the interface (as shown)
Unity3d game Development explains how to make a form using Ngui