示例#1
0
    /// <summary>
    /// 获取bundle,如果bundle不属于本loader的,则请求父亲节点
    /// 判断bundle是否属于本loader,是简单的对bundle名字对比,bundle名字是由本loader的module name开头的
    /// 就认为是本loader的
    /// </summary>
    /// <param name="bundleName"></param>
    /// <returns></returns>
    private AssetBundle GetBundle(string bundleName)
    {
        // 判断是否本loader管理的bundle
        if (!IsMyBundle(bundleName))
        {
            if (parent != null)
            {
                return(parent.GetBundle(bundleName));
            }

            Debug.LogError($"{bundleName} not {moduleName}'s bundle, load bundle failed");
            return(null);
        }

        if (bundleMap.ContainsKey(bundleName))
        {
            return(bundleMap[bundleName]);
        }
        else
        {
            // try to load bundle
            return(LoadBundleFromFile(bundleName));
        }
    }