Beispiel #1
0
    public static void PushUI <T>() where T : class, IUI, new()
    {
        IUI uI = FindUI <T>();

        uI.OnCreate();
        if (mUIStack.Count > 0)
        {
            mUIStack.Peek().OnFrozen(true);
        }
        mUIStack.Push(uI);
    }
Beispiel #2
0
    public void Create(string name)
    {
        if (uiDic.ContainsKey(name))
        {
            Debug.LogError("ui " + name + " already exists in uiDic!");
            return;
        }

        AssetBundleManager.Instance.Load(Define.ResourcesPath + "UI." + name + ".prefab", (o) =>
        {
            if (o == null)
            {
                Logger.LogError("o is null");
                return;
            }

            GameObject go = o.Instantiate();
            if (go == null)
            {
                Logger.LogError("ui " + name + " Instantiate failed!");
                return;
            }

            go.transform.SetParent(rootTrans);
            go.transform.localPosition = Vector3.zero;
            go.transform.localScale    = Vector3.one;
            IUI ui = go.AddComponent(System.Type.GetType(name)) as IUI;
            if (ui == null)
            {
                Logger.LogError("ui " + name + " AddComponent failed!");
                return;
            }

            uiDic.Add(name, ui);
            ui.OnCreate();
        });
    }