Skip to content

UI System

高凯 edited this page Dec 1, 2017 · 3 revisions

UI system

UI manager open as: Window -> UI编辑器工具(UI editor tools)

UI Editor Tool

Create UIManager:

Select UIManger tab:
Choose the resolution
Choose whether there is only one UI camera, whether vertical screen and so on.
Click 创建UIManager(Create UIManager)

Create UI:

Select 创建UI(Create UI) tab: Enter UI Name,
Select UIType, UIType used to set the occlusion between the UI, this can also be created in the perfab.
UIType is divided into five kinds of GameUI, Fixed, Normal, Top Bar, Pop Up
 GameUI at the bottom of the UI hierarchy, generally used for the blood inside the game, floating UI.
 Fixed above the GameUI layer, generally used for resident UIs such as the main city UI.
 Normal is above Fixed and is typically used for normal UIs such as stores.
 TopBar is above normal and is generally used for resident top-pointing UIs such as physical and monetary UI.
 Pop UP at the top, generally used to display the pop-up window.

Choose whether or not to use Lua, and if so, automatically bind the Lua adaptation script and create the corresponding Lua file.
If not, C # scripts are automatically created and bound.
  
After entering the UI's name correctly, click 创建UI脚本(Create UI Script) and the framework will automatically create a class named UIName + Window suffix in the Script / UI / UINameWindow folder.
After Unity compiles and completes, clicks 创建UI(Create UI), will establish a bound UINameWindow presupposes under Resources / UI / UINameWindow folder automatically.

After creating a new UI, remember to rebuild the inventory under 打包设置管理器(Package Settings Manager).

Create UI Template:

The document is being completed.

Create UI style:

The document is being completed.

API

UI is managed by UIManager

Open a UI
public static UIWindowBase OpenUIWindow (string UIName, UICallBack callback = null, params object [] objs)
Open a specified type of UI
public static T OpenUIWindow <T> () where T: UIWindowBase
Close a UI
public static void CloseUIWindow (UIWindowBase UI, bool isPlayAnim = true, UICallBack callback = null, params object [] objs)
Close a UI
public static void CloseUIWindow (string UIname, bool isPlayAnim = true, UICallBack callback = null, params object [] objs)
Close a specified type of UI
public static void CloseUIWindow <T> (bool isPlayAnim = true, UICallBack callback = null, params object [] objs) where T: UIWindowBase

The document is being completed

Example

public class GameStatus: IApplicationStatus
{
    public override void OnEnterStatus ()
    {
        OpenUI <GameWindow> ();

        UIManager.OpenUIWindow <ShopWindow> ();
    }
}
Clone this wiki locally