Пример #1
0
    public void RegistResource(string path, OnResourceReady cb, System.Object callbackObj)
    {
        if (UnityTools.IsPackageResource(path))
        {
            SRes iRes = m_lResKeyList.Find(SRes.MatchPath(path));
            if (iRes != null && iRes.BundleRes.resource != null)
            {
                cb(path, iRes.BundleRes.resource, callbackObj);
            }
            else
            {
                SPendingRequest request = new SPendingRequest();
                request.path = path;
                request.callback = cb;
                request.callbackObj = callbackObj;
                m_ltPendingRequest.Add(request);

                if(null == iRes)
                {
                    iRes = new SRes(path, iLoader.LoadResource(path));
                    m_lResKeyList.Add(iRes);
                    iRes.BundleRes.SetEventListener(HandlePackageResourceEvent);
                }
                //StartCoroutine(TestLoad(path, cb, callbackObj));
            }

        }
        else
        {
            UnityEngine.Object resObj = RegistResource(path);
            //TODO 后续这里加一些判断
            cb(path, resObj, callbackObj);
        }
    }
Пример #2
0
    IEnumerator TestLoad(string path, OnResourceReady cb, System.Object callbackObj)
    {
        string tmpPath = "file://C:/Projects/U3DFrame/Assets/StreamingAssets/package_ui.bytes";
        path = "file://" + GameConst.ResRootPath +  UnityTools.GetPackageName(path) + ".bytes";
        Debug.Log(tmpPath);
        WWW www = WWW.LoadFromCacheOrDownload(tmpPath, 0);
        yield return www;

        //         byte[] bytes = File.ReadAllBytes(path);
        //         AssetBundle bundle = AssetBundle.LoadFromMemory(bytes);
        //UnityEngine.Object obj = bundle.LoadAsset("Assets/Art/package_ui/test.prefab");

        //Debug.Log("obj === " + obj);
        //GameObject go = GameObject.Instantiate(obj) as GameObject;
        Debug.LogError("load bundle === " + www.assetBundle);
        yield return 0;
    }