[CB] ngui Event Management

Source: Internet
Author: User

I have read many articles about ngui event management. Many people encapsulate an event processing layer to avoid binding event processing scripts to each UI control. Our project practice is to bind the uieventlistener script to every control that requires event processing.

Then each UI uses a scene, and each UI corresponds to a Cui class.

For example, the CB-art project/product/UI/battle. Unity [combat UI] uses the export function to package the current UI into a separate assetbundle. Dynamically Loaded to the CB-clien Project

In CB-Client/code/UI/cuibattle. CS [combat Interface UI processing], use a class to process the UI loaded in this assetbunld separately.

Note: Each UI has a class corresponding to its own name. [Eg: Home. Unity-> cuihome]

For example:

Void Init ()

{

Pausepanel. getcomponent <uieventlistener> (). onclick = new uieventlistener. voiddelegate (OBJ) => pausepanel. gameobject. setactive (false ));

Gmbtn = getcontrol <uibutton> ("gmbtn ");
Gmbtn. getcomponent <uieventlistener> (). onclick = gmbtnclick;

}

In this way, the amount of code files is relatively large, but the code is better managed, and UI error detection is more convenient.

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.