Esempio n. 1
0
    /// <summary>
    /// 加载bundle
    /// </summary>
    /// <param name="path"></param>
    /// <param name="callback"></param>
    /// <param name="prority"></param>
    public FastAssetBundleLoader LoadBundle(string path, FastLoadAssetCompleteHandler callback = null, int prority = 0)
    {
        Init();
        FastAssetBundleLoader loader = CreateLoader(path + FastContent.BundleSuffix, path);

        loader.AddListener(callback);
        loader.Start();
        return(loader);
    }
Esempio n. 2
0
 internal FastAssetBundleInfo CreateBundleInfo(FastAssetBundleLoader loader, FastAssetBundleInfo abi = null, AssetBundle assetBundle = null)
 {
     if (abi == null)
     {
         abi = new FastAssetBundleInfo();
     }
     abi.bundleName = loader.bundleName.ToLower();
     abi.bundle     = assetBundle;
     return(abi);
 }
Esempio n. 3
0
 /// <summary>
 /// 检查下载情况,发现有需要下载的就立马跟上
 /// </summary>
 void QueueCheck()
 {
     //如果下载线程没有达到最大量,等待线程又有需要下载项
     if (onloadingbundleLoader.Count < MaxLoadingThread && waitloadingbundleLoader.Count > 0)
     {
         for (int i = 0; i < MaxLoadingThread; i++)
         {
             FastAssetBundleLoader loader = waitloadingbundleLoader.Dequeue();
             onloadingbundleLoader.Push(loader);
             loader.LoadBundle();
             if (waitloadingbundleLoader.Count <= 0)
             {
                 break;
             }
         }
     }
 }
Esempio n. 4
0
    internal FastAssetBundleLoader CreateLoader(string abFileName, string oriName = null)
    {
        FastAssetBundleLoader loader = null;

        if (AllAssetBundleLoaders.ContainsKey(abFileName))
        {
            loader = AllAssetBundleLoaders[abFileName];
        }
        else
        {
            loader = this.CreateLoader();
            loader.bundleManager = this;
            loader.Main_Manifest = this.mainAssetBundleMainfest;
            loader.bundleName    = abFileName;

            AllAssetBundleLoaders.Add(abFileName, loader);
        }

        return(loader);
    }
Esempio n. 5
0
    /// <summary>
    /// 先加载依赖项
    /// </summary>
    void LoadDepends()
    {
        if (depLoaders == null)
        {
            string[] dependencies = GetDepensdList();
            depLoaders = new FastAssetBundleLoader[dependencies.Length];
            for (int i = 0; i < dependencies.Length; i++)
            {
                depLoaders[i] = bundleManager.CreateLoader(dependencies[i]);
            }
        }

        for (int i = 0; i < depLoaders.Length; i++)
        {
            FastAssetBundleLoader depLoader = depLoaders[i];
            if (!depLoader.isComplete)
            {
                depLoader.AddListener(OnDepComplete);
                depLoader.Start();
            }
        }
    }
Esempio n. 6
0
 /// <summary>
 /// 最底层的依赖项应该在最优先加载的栈顶
 /// </summary>
 /// <param name="dependLoader"></param>
 public void AddDependBundle(FastAssetBundleLoader dependLoader)
 {
     waitloadingbundleLoader.Enqueue(dependLoader);
 }