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.