Unity3d game Development explains how to make a form using Ngui

Source: Internet
Author: User

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 ();
    1. //set selected object default color change
    2.             _secondclickobject.getcomponent<uibutton > (). defaultcolor = new Color (21f/255f, 122f/255f, 2f/255f, 1f);
    3. < BR style= "" >
    4.             //Restore First selected object default color
    5.             _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.

  1. <summary>
  2. Judging Click Object
  3. </summary>
  4. <param name= "Item" > Selected Item Object </param>
  5. public void SelectItem (Gameobject item)
  6. {
  7. Currently selected item object
  8. GAMEDATA.CURRGAMEOBEJCT = Item;

  9. Judge two times the selected object, the first selected, the second selected
  10. if (_firstclickobject = = null)
  11. {
  12. _firstclickobject = Item;

  13. Sets the default color change for the selected object
  14. _firstclickobject.getcomponent<uibutton> (). DefaultColor = new Color (21f/255f, 122f/255f, 2f/255f, 1f);

  15. if (_secondclickobject! = null)
  16. {
  17. Restores the default color of the second selected object
  18. _secondclickobject.getcomponent<uibutton> (). Resetdefaultcolor ();

  19. _secondclickobject = null;
  20. }
  21. Return
  22. }
  23. Else
  24. {
  25. _secondclickobject = Item;
  26. Sets the default color change for the selected object
  27. _secondclickobject.getcomponent<uibutton> (). DefaultColor = new Color (21f/255f, 122f/255f, 2f/255f, 1f);

  28. Restores the default color of the first selected object
  29. _firstclickobject.getcomponent<uibutton> (). Resetdefaultcolor ();

  30. _firstclickobject = null;
  31. }
  32. }
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

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.