- Getting Start
- Project Settings
- Rich Text
- Cocos Creator
- Cry Engine
SDK - Unity
- Insert 3D
- Curved UI
In the UI system, we often need to pop up some components, and these components will automatically disappear when the user clicks on a blank space. FairyGUI has this feature built in.
The API to pop and close Popup is provided in GRoot.
ShowPopupPop up a component. If a target is specified, the pop-up position will be adjusted below the target, forming a drop-down effect. Parameters are also provided to specify whether to pop up or pop down. FairyGUI automatically calculates the pop-up position based on the size of the component to ensure that the component display does not exceed the screen. E.g:// popup at current mouse positionGRoot.inst.ShowPopup (aComponent);// pop up below aButtonGRoot.inst.ShowPopup (aComponent, aButton);// popup at custom positionGRoot.inst.ShowPopup (aComponent);aComponent.SetXY (100, 100);
The window can also be popped up through ShowPopup, so the pop-up window also has the feature of clicking blank to close:Window aWindow;GRoot.inst.ShowPopup (aWindow);// The only difference from using aWindow.Show to display the window is that it has the function of clicking blank to close, there is no difference in other usage.
HidePopupBy default, the pop-up component is automatically closed when the user clicks on a blank space. You can also call this API to close it manually. You can specify the Popup that needs to be closed. When no parameter is specified, all current popups are closed.
The pop-up box will automatically close when you click on the blank space. If you want to be notified of this shutdown, you can listen to the event of moving out of the stage, for example:
PopupMenu is a tool class provided by FairyGUI for implementing popup menus. First you need to make a menu component in the editor, click “Resources-> New Popup Menu …”, and then follow the wizard to complete. The key element in the menu component is named
listFor the list component, the overflow processing mode of the list should be selected as visible, because in general, the menu displays all items without scrolling.
After making the menu component, this menu can be generated and called in the code.
First set the global menu resources: