Beispiel #1
0
//		public void Request(string url, ResourceType type, int version, ThreadPriority priority)
//		{
//			Request (url, type, version, priority, false);
//		}

    public void Request(string url, ResourceType type, ThreadPriority priority, bool noticeError = false)
    {
        //Debug.LogError("Request www url:"+url);
        if (!mWorkingPool.ContainsKey(url) && !mStoragePool.ContainsKey(url))
        {
            //Debug.Log("mWaitingPool.Count"+mWaitingPool.Count);
            DownLoadUnitReq req = new DownLoadUnitReq();
            req.mUrl  = url;
            req.mType = type;
            //req.mVersion = version;
            req.mPriority = priority;
            //req.compress = comp;
            req.noticeError = noticeError;
            switch (priority)
            {
            default:
            case ThreadPriority.Normal: mNormalWaitingPool.Enqueue(req); break;

            case ThreadPriority.Low: mLowWaitingPool.Enqueue(req); break;
            }
            ProcessManager.Add(Instance);
            //Debug.Log("mNormalWaitingPool.Count"+mNormalWaitingPool.Count);
            //Debug.Log("mLowWaitingPool.Count"+mLowWaitingPool.Count);
        }
    }
Beispiel #2
0
    public DownLoadUnit(DownLoadUnitReq req)
    {
        mReq = req;
        string filePath = GameInfo.FilePath + req.mUrl + req.mExtention;


        if (req.mType == ResourceType.RT_ASSETBUNDLE)
        {
            string url = DownLoadUrl.BaseURL(req.mType) + req.mUrl;
            if (!url.EndsWith(req.mExtention))
            {
                url += req.mExtention;
            }
            Debug.Log("LoadAssetBundle>>>>>>>>>>>>>>>>>:" + url);
            mWWW = new WWW(url);
        }
        else if (req.mType == ResourceType.RT_STREAM)
        {
            string streamPath = DownLoadUrl.BaseURL(req.mType) + req.mUrl;
            if (!streamPath.EndsWith(req.mExtention))
            {
                streamPath += req.mExtention;
            }
            Debug.Log("streamPath>>>>>>>>>>>>>>>>>:" + streamPath);
            mWWW = new WWW(streamPath);
        }

        else if (File.Exists(filePath))
        {
            Debug.Log("WWWFromFilePath>>>>>>>>>>>>>>>>>:" + filePath);
            mWWW = new WWW("file:///" + filePath);
        }
        else
        {
            string url = DownLoadUrl.BaseURL(req.mType) + req.mUrl;
            if (!url.EndsWith(req.mExtention))
            {
                url += req.mExtention;
            }
            Debug.Log("WWW>>>>>>>>>>>>>>>>>:" + url);
            mWWW = new WWW(url);
        }
        mWWW.threadPriority = req.mPriority;
    }
Beispiel #3
0
    public void Update(float deltaTime)
    {
        //Debug.Log("Update:"+deltaTime);

        foreach (KeyValuePair <string, DownLoadUnit> keyVal in mWorkingPool)
        {
            //Debug.Log("test");
            if (keyVal.Value.Loaded())
            {
                //Debug.LogError("loaded:"+keyVal.Key);
                mStoragePool.Add(keyVal.Key, keyVal.Value);
                mWorkingPool.Remove(keyVal.Key);
                break;
            }
        }

        if (mWorkingPool.Count < mMaxLoads)
        {
            //Debug.Log("Update1:"+deltaTime);

            if (mNormalWaitingPool.Count > 0)
            {
                //Debug.Log("Updat2:"+deltaTime);
                DownLoadUnitReq req = mNormalWaitingPool.Dequeue();
                if (!mWorkingPool.ContainsKey(req.mUrl) &&
                    !mStoragePool.ContainsKey(req.mUrl))
                {
                    //Debug.LogError("req.mUrl:"+req.mUrl+">>>>"+mWorkingPool.Count);
                    mWorkingPool.Add(req.mUrl, new DownLoadUnit(req));
                }
            }
            else if (mLowWaitingPool.Count > 0)
            {
                DownLoadUnitReq req = mLowWaitingPool.Dequeue();
                if (!mWorkingPool.ContainsKey(req.mUrl) &&
                    !mStoragePool.ContainsKey(req.mUrl))
                {
                    mWorkingPool.Add(req.mUrl, new DownLoadUnit(req));
                }
            }
        }
    }