public Object[] LoadAllRes(string bundleName, string res)
 {
     if (m_dicAssetBundle.ContainsKey(bundleName))
     {
         AssetBundleUnit tmpAB = m_dicAssetBundle[bundleName];
         return(tmpAB.LoadAllRes(res));
     }
     return(null);
 }
    public IEnumerator LoadAssetBundle(string path)
    {
        WWW tmpLoader = new WWW(path);

        while (!tmpLoader.isDone)
        {
            yield return(tmpLoader);
        }
        AssetBundleUnit unit = new AssetBundleUnit();

        unit.m_assetBunble = tmpLoader.assetBundle;
        m_dicAssetBundle.Add(m_assetBundleName, unit);
    }
Exemple #3
0
    /// <summary>
    /// 根据AB包名同步加载AssetBundle
    /// </summary>
    private AssetBundle SyncLoadAssetBundle(string assetBundleName)
    {
        AssetBundleUnit unit = null;

        if (!mAssetBundleUnitDict.TryGetValue(assetBundleName, out unit))
        {
            var path        = PathUtil.GetLocalAssetBundleFilePath(assetBundleName);
            var assetBundle = AssetBundle.LoadFromFile(path);
            if (assetBundle == null)
            {
                Debugger.LogError("Load AssetBundle Error: " + assetBundleName);
                return(null);
            }
            unit             = mAssetBundleUnitPool.Spawn();
            unit.AssetBundle = assetBundle;
            unit.RefCount++;
            mAssetBundleUnitDict.Add(assetBundleName, unit);
        }
        else
        {
            unit.RefCount++;
        }
        return(unit.AssetBundle);
    }