Esempio n. 1
0
    //----------------------------------------------------------------//

    ///////////////////////////MainFunctions////////////////////////////
    public static Object GetInstantiateOB(string resName, ResType resType, ResCacheType cacheType = ResCacheType.Never)
    {
        ResKey  reskey = new ResKey(resType, resName);
        ResItem resItem;

        if (!ressDic.ContainsKey(reskey))
        {
            Object ob = LoadObj(resType, resName);
            if (ob != null)
            {
                resItem = new ResItem(ob, cacheType);
                ressDic.Add(reskey, resItem);
            }
            else
            {
                resItem = null;
            }
        }
        else
        {
            resItem = ressDic[reskey];
        }

        if (!ressDic.ContainsKey(reskey))
        {
            Debug.LogError("Load Res:" + reskey.name + "Error!");
            return(null);
        }
        return(Instantiate(resItem.obj));
    }
Esempio n. 2
0
 public PWindowType(WindowBase windowBase, ResType resType, ResCacheType cacheType)
 {
     this.windowBase = windowBase;
     this.resType    = resType;
     this.cacheType  = cacheType;
 }
Esempio n. 3
0
    //预加载窗口物体进缓存
    public void InitWindowCache(PEWindowEnum windowEnum, ResType resType, string luaName = "", ResCacheType cacheType = ResCacheType.Never)
    {
        PWindow    pwindow    = new PWindow(windowEnum, luaName);
        string     windowName = pwindow.windowName;
        GameObject gb         = null;

        if (!windowDic.ContainsKey(pwindow))
        {
            gb                         = (GameObject)ResourceMgr.GetInstantiateOB(windowName, resType, cacheType);
            gb.name                    = windowName;
            gb.transform.parent        = windowRootTrans;
            gb.transform.localPosition = Vector3.zero;
            gb.transform.localScale    = Vector3.one;
            NGUITools.SetActive(gb, false);
            WindowBase windowBase = gb.GetComponent <WindowBase>();
            if (windowBase == null)
            {
                windowBase = GetOrAddWindowHandle(gb, windowEnum, luaName);
                if (windowBase == null)
                {
                    Debug.LogError("Can not Get " + windowName + " Handle Scripts");
                    return;
                }
            }
            windowDic.Add(pwindow, new PWindowType(windowBase, resType, cacheType));
            windowBase.InitDic();
        }
    }
Esempio n. 4
0
 public ResCacheConfig(ResCacheType cacheType, int resId = S_ALL_RES)
 {
     CacheType = cacheType;
     ResId     = resId;
 }
Esempio n. 5
0
 public ResItem(Object obj, ResCacheType cacheType)
 {
     this.obj       = obj;
     this.cacheType = cacheType;
 }