Ejemplo n.º 1
0
    public IURLLoader asynLoad(string url, ListenDelegate dele, bool autoDelete, bool errNotify)
    {
        url = url.Trim();
        if ("" == url || false == url.EndsWith(".u3d"))
        {
            throw new Exception("AsynResourceMgr -> ansynLoad() -> url[" + url + "] is empty or not end with .u3d");
        }

        //
        if (!_URLLoaders.ContainsKey(url))
        {
            URLLoader lo = new URLLoader();
            lo.url = url;
            if (fileVers.ContainsKey(url))
            {
                lo.fileVersion = fileVers[url];
            }
            lo.fullUrl = fullUrl(url, lo.fileVersion);
            _URLLoaders.Add(url, lo);
//			Debug.Log("=============== url: "+url+"   verson: "+lo.fileVersion+" =============");
        }

        URLLoader loader = _URLLoaders[url] as URLLoader;

        // add listener
        loader.addListener(dele, errNotify);

        // auto delete
        if (loader.autoDelete == true)
        {
            loader.autoDelete = autoDelete;
        }
        if (_delayAutoDelete)
        {
            loader.preventAutoDelete = true;
        }

        URLLoaderState state = loader.state;

        if (state == URLLoaderState.unload)
        {
            putinWaitingList(loader);
            fullDownload();
        }
        else if (state == URLLoaderState.waiting || state == URLLoaderState.loading)
        {
            //nothing
        }
        else if (state == URLLoaderState.loaded || state == URLLoaderState.error)
        {
            //enter to notify list, next update to notify user
            _notifyList.Add(loader);
        }

        return(loader);
    }
Ejemplo n.º 2
0
    public void destroySelf(bool unloadAllLoadedObjects)
    {
        listeners.Clear();

        if (state == URLLoaderState.loading)
        {
            www.Dispose();
        }
        else if (state == URLLoaderState.loaded)
        {
            //if(www.assetBundle != null)       //you can't access 'www.assetBundle' here, it will raise an error
            www.assetBundle.Unload(unloadAllLoadedObjects);
            www.Dispose();
        }
        else if (state == URLLoaderState.error)
        {
            www.Dispose();
        }

        www = null;

        state = URLLoaderState.destroyed;
    }