示例#1
0
    /// 加载AB
    public static IEnumerator  LoadABasync(string ABPath, bool IsCache, ABLoadHook pfun)
    {
        AssetBundle AB = FindAB(ABPath);

        if (AB == null)
        {
            string abpath = ConstantData.ABSavePath + ABPath;
            if (File.Exists(abpath) == true)
            {
                byte[] stream = null;
                stream = File.ReadAllBytes(abpath);
                AssetBundleCreateRequest ABquest = AssetBundle.LoadFromMemoryAsync(stream);
                yield return(ABquest);

                AB = ABquest.assetBundle;
                if (AB != null && IsCache)
                {
                    AddABCache(ABPath, AB);
                }
            }
        }

        if (pfun != null)
        {
            pfun(AB);
        }
    }
    /// 异步加载AB
    public static IEnumerator LoadABasync(string ABPath, bool IsCache, ABLoadHook pfun)
    {
        AssetBundle ab = FindAB(ABPath);

        if (ab == null)
        {
            string abpath = GetAssetBundlePath(ABPath);

            AssetBundleCreateRequest ABquest = AssetBundle.LoadFromFileAsync(abpath);
            yield return(ABquest);

            ab = ABquest.assetBundle;

            if (ab == null)
            {
                Debug.Log("ABLoad load ab fail :" + abpath);
            }
            else
            {
                if (IsCache)
                {
                    AddABCache(ABPath, ab);
                }
            }
        }

        if (pfun != null)
        {
            pfun(ab);
        }
    }
示例#3
0
    /// <summary>
    /// 异步的ab包加载
    /// 现在暂时是同步加载
    /// </summary>
    /// <param name="abPath"></param>
    /// <param name="isCache"></param>
    /// <param name="callback"></param>
    public static void LoadAB(string abPath, bool isCache, ABLoadHook callback)
    {
        AssetBundle AB = LoadAbSync(abPath, isCache);

        if (callback != null)
        {
            callback(AB);
        }
    }
    /// <summary>
    /// 异步的ab包加载
    /// 现在暂时是同步加载
    /// </summary>
    /// <param name="abPath"></param>
    /// <param name="isCache"></param>
    /// <param name="callback"></param>
    public static void LoadAB(string abPath, bool isCache, ABLoadHook callback)
    {
        AssetBundle AB = LoadAbSync(abPath, isCache);

        if (AB == null)
        {
            Debug.Log("ab res load error: " + abPath);
        }
        if (callback != null)
        {
            callback(AB);
        }
    }