Ejemplo n.º 1
0
        private IEnumerator asyncLoadBundle(UniResOperation _op, string _bundle, OnLoadBundleFinishDelegate _finish)
        {
            string dir = Application.streamingAssetsPath;

            if (externalBundles.Contains(_bundle))
            {
                dir = Application.persistentDataPath;
            }
            if (!dir.Contains("file://"))
            {
                dir = dir.Insert(0, "file://");
            }
            string path = System.IO.Path.Combine(dir, "res/" + _bundle);
            WWW    www  = new WWW(path);

            _op.Use(www);
            yield return(www);

            if (null != www.error)
            {
                this.LogError(www.error);
                yield break;
            }
            AssetBundle bundle = www.assetBundle;

            if (null == bundle)
            {
                this.LogError("bundle is null");
                yield break;
            }
            bundles.Add(_bundle, bundle);
            www.Dispose();
            _op.Use(1.0f);
            _finish(bundle);
        }
Ejemplo n.º 2
0
 public static IResOpeartion AsyncLoadBundle(string _bundle, OnLoadBundleFinishDelegate _finish)
 {
     if (null == resLoaderImpl)
     {
         Log.Error("ResBundle", "resLoaderImpl is null");
         return(null);
     }
     return(resLoaderImpl.AsyncLoadBundle(_bundle, _finish));
 }
Ejemplo n.º 3
0
        private static void addBundleTask(string _bundle, OnLoadBundleFinishDelegate _onFinish)
        {
            Task task = new Task();

            task.bundle         = _bundle;
            task.res            = "";
            task.type           = Task.TYPE_BUNDLE;
            task.onBundleFinish = _onFinish;
            tasks.Enqueue(task);
        }
Ejemplo n.º 4
0
        public IResOpeartion AsyncLoadBundle(string _bundle, OnLoadBundleFinishDelegate _finish)
        {
            UniResOperation op = new UniResOperation();

            if (!bundles.ContainsKey(_bundle))
            {
                this.LogDebug("Load Bundle {0} ... ", _bundle);
                mono.StartCoroutine(asyncLoadBundle(op, _bundle, (_ab) =>
                {
                    this.LogDebug("Load Bundle {0} finish", _bundle);
                    _finish(_ab);
                }));
            }
            else
            {
                op.Use(1.0f);
                this.LogDebug("Load exits Bundle {0}", _bundle);
                _finish(bundles [_bundle]);
            }
            return(op);
        }
Ejemplo n.º 5
0
 public static void AddBundleTask(string _bundle, OnLoadBundleFinishDelegate _onFinish)
 {
     addBundleTask(_bundle, _onFinish);
 }