Example #1
0
        /// <summary>
        /// 添加到队列
        /// </summary>
        /// <param name="loader">使用的加载器</param>
        /// <returns></returns>
        public UrlLoadQueue Add(UrlLoader loader)
        {
            if (isLoading)
            {
                throw new Exception("can't add on loading");
            }
            if (string.IsNullOrEmpty(loader.config.GUID))
            {
                throw new Exception("AssetGUID = NUll");
            }
            string assetID = loader.config.GUID;

            string version = "";//loader.config.Version.RemoteVersion;

            if (_loaders.ContainsKey(assetID))
            {
                if (version != _loaders[assetID].version)//版本更新
                {
                    _loaders[assetID].version = version;
                }
            }
            else
            {
                _loaders.Add(assetID, new UrlLoadQueueData(loader, assetID, version, retry));
                _urls.Add(assetID);
            }
            return(this);
        }
Example #2
0
 public UrlLoadQueueData(UrlLoader loader, string url, string version, int retry = 0)
 {
     this.urlLoader = loader;
     this.url       = url;
     this.version   = version;
     this.maxRetry  = retry;
 }
Example #3
0
        // Use this for initialization
        private void Start()
        {
            UrlLoader  loader  = new UrlLoader();
            UrlRequest request = new UrlRequest("http://docs.unity3d.com/ScriptReference/index.html", OnComplete, OnError);

            //UrlRequest request = new UrlRequest("http://docs.unity3d.com/xxx", OnComplete, OnError);
            loader.Load(request);
        }
Example #4
0
    public static T GetLoader <T>(DownLoadAgent config) where T : UrlLoader
    {
        UrlLoader loader = null;

        if (Loaders.TryGetValue(config.GUID, out loader))
        {
            if (loader is T)
            {
                return(loader as T);
            }
            else
            {
                DebugConsole.Warning("LoaderFactory", "GetLoader", "同一个资源文件被不同的类型请求");
                return(null);
            }
        }
        loader = ReflecTool.Instantiate <T>(new Type[] { typeof(DownLoadAgent) }, new object[] { config });
        Loaders[config.GUID] = loader;
        return(loader as T);
    }
Example #5
0
        public void LoadMidiUrl(string url)
        {
            if (State != SynthPlayerState.Stopped)
            {
                return;
            }
            Logger.Info("Start loading midi from url " + url);
            var loader = new UrlLoader();

            loader.Url      = url;
            loader.Method   = "GET";
            loader.Complete = LoadMidiBytes;
            loader.Progress = OnLoaderMidiLoad;
            try
            {
                loader.Load();
            }
            catch (Exception e)
            {
                Logger.Error("Could not load midi from url: " + e);
            }
        }