Ejemplo n.º 1
0
    internal void GetUICache <T>(Action <T> finishCallback = null) where T : BaseUI, new()
    {
        var type = typeof(T);

        if (uiCacheDic.ContainsKey(type))
        {
            var ui = (T)uiCacheDic[type];
            finishCallback?.Invoke(ui);
        }
        else
        {
            ////Logx.LogError("loadUI : the type is not found : " + type);
            //return null;

            var uiConfigInfo = UIConfigInfoDic.GetInfo <T>();
            //这里之后改成 resourceManager 加载的 go
            ResourceManager.Instance.GetObject <GameObject>(uiConfigInfo.path, (gameObject) =>
            {
                gameObject.transform.SetParent(this.uiRoot, false);
                T t = new T();
                t.Init(gameObject, uiConfigInfo.path);
                uiCacheDic.Add(t.GetType(), t);
                finishCallback?.Invoke(t);
            });
        }
    }
Ejemplo n.º 2
0
    public void ReleaseUI <T>()
    {
        var type = typeof(T);

        if (uiCacheDic.ContainsKey(type))
        {
            var ui = uiCacheDic[type];
            uiCacheDic.Remove(type);
            ui.Release();

            var uiConfigInfo = UIConfigInfoDic.GetInfo <T>();
            ResourceManager.Instance.ReturnObject <GameObject>(uiConfigInfo.path, ui.gameObject);
            //AssetManager.Instance.Release(uiConfigInfo.path);
        }
        else
        {
            //Logx.LogWarning("the ui is not exist in cache dic : " + type);
        }
    }