private static void AddAsset(ABBundleInfo buildInfo, ABAssetData cacheData)
 {
     if (buildInfo != null && cacheData != null &&
         buildInfo.bundleId.version >= cacheData.version)
     {
         cacheData.bundleId = buildInfo.bundleId;
     }
 }
    public static ABAssetInfo LoadAssetData(string prefabPath)
    {
        string[]    depends    = AssetDatabase.GetDependencies(prefabPath, true);
        ABAssetData assetCache = new ABAssetData();

        assetCache.filePath = prefabPath;
        assetCache.fileHash = HashUtil.GetByPath(Application.dataPath + "/../" + prefabPath);
        assetCache.depends  = depends;
        assetCache.bundleId = m_curretBundleID;
        return(new ABAssetInfo(assetCache));
    }
Exemplo n.º 3
0
    public override bool Equals(object obj)
    {
        ABAssetData mountId = obj as ABAssetData;

        if (mountId != null)
        {
            if (mountId.isIgnoreMd5)
            {
                return(true);
            }
            return(mountId.fileHash == fileHash);
        }
        else if (X2AssetsBundleEditor.m_isIgnoreDic.ContainsKey(filePath))
        {
            return(X2AssetsBundleEditor.m_isIgnoreDic[filePath]);
        }
        return(false);
    }
Exemplo n.º 4
0
 public ABAssetInfo(ABAssetData cacheData)
 {
     m_cacheData = cacheData;
 }
    public static void ProcessCacheDic(bool isUpdate = false)
    {
        List <ABAssetData> shaderlist = new List <ABAssetData>();

        foreach (var keyvalue in m_abbuildDic)
        {
            keyvalue.Value.fileList.Clear();
        }

        foreach (var keyvalue in m_dependsDic)
        {
            if (!isUpdate)
            {
                if (m_abbuildDic.ContainsKey(keyvalue.Value.m_cacheData.bundleId))
                {
                    var buildInfo = m_abbuildDic[keyvalue.Value.m_cacheData.bundleId];
                    if (buildInfo != null)
                    {
                        AddAsset(buildInfo, keyvalue.Value.m_cacheData);
                    }
                }
            }
            else
            {
                ABAssetData oldCache  = null;
                var         newCache  = keyvalue.Value.m_cacheData;
                var         assetInfo = keyvalue.Value;

                ABBundleInfo build = null;
                if (!m_abbuildDic.TryGetValue(newCache.bundleId, out build))
                {
                    build          = new ABBundleInfo();
                    build.bundleId = newCache.bundleId;
                    m_abbuildDic.Add(newCache.bundleId, build);
                }
                m_oldDic.TryGetValue(keyvalue.Key, out oldCache);
                ABBundleInfo oldBuild = null;
                if (oldCache != null && m_abbuildDic.ContainsKey(oldCache.bundleId))
                {
                    oldBuild = m_abbuildDic[oldCache.bundleId];
                }
                if (newCache.bundleType == EnumAB.shaders_ab)
                {
                    if (oldCache != null)
                    {
                        continue;
                    }

                    //shader有修改  重新build所有shader就好
                    if (!newCache.Equals(oldCache))
                    {
                        //重新打 将已经处理过的shader都移动到最新的version
                        m_isUpdateShader = true;
                        if (shaderlist.Count != 0)
                        {
                            foreach (var shader in shaderlist)
                            {
                                build.bundleId = new BundleID(m_curVersion, EnumAB.shaders_ab);
                                AddAsset(build, shader);
                            }
                            shaderlist.Clear();
                        }
                    }
                    if (m_isUpdateShader)
                    {
                        build.bundleId = new BundleID(m_curVersion, EnumAB.shaders_ab);
                        AddAsset(build, newCache);
                    }
                    else
                    {
                        // shaderlist 用来处理原来的没有修改过的shader,当后面发现有shader修改,那么需要把之前觉得不需要的改的shader都修改了
                        shaderlist.Add(newCache);
                        AddAsset(oldBuild, newCache);
                    }
                }
                else if (newCache.bundleType == EnumAB.uialtas_ab)
                {
                    //图集的定义是图集除了引用shader之外不会引用任何其他图集,而且有另外一套图集引用关系
                    var newBuildCache = assetInfo.m_cacheData;
                    if (newBuildCache.Equals(oldCache))
                    {
                        AddAsset(oldBuild, newCache);
                    }
                    else
                    {
                        //图集有修改  新建一个 version_uiAtlas_ab的assetbundle 并且把所有相关的放到这儿来
                        build = GetUpdateABBuild(EnumAB.uialtas_ab);
                        AddAsset(build, newBuildCache);
                        TransToSelf(assetInfo, EnumAB.uialtas_ab);
                    }
                }
                else if (newCache.bundleType == EnumAB.scene_ab)
                {
                    var newBuildCache = assetInfo.m_cacheData;
                    if (newBuildCache.Equals(oldCache))
                    {
                        AddAsset(oldBuild, newCache);
                    }
                    else
                    {
                        //场景有改变 需要重新打包这个场景它的和它的子引用,要更新它的子引用是怕它有增加一个模型
                        build = GetUpdateABBuild(EnumAB.scene_ab, newCache.bundleId.sceneName);
                        AddAsset(build, newBuildCache);
                        var scenePrefabBuild = GetUpdateABBuild(EnumAB.scenemodle_ab);
                        foreach (var child in assetInfo.m_children)
                        {
                            AddAsset(scenePrefabBuild, child.m_cacheData);
                        }
                    }
                }
                else if (newCache.bundleType == EnumAB.scenemodle_ab)
                {
                    var newBuildCache = assetInfo.m_cacheData;
                    if (newBuildCache.Equals(oldCache))
                    {
                        AddAsset(oldBuild, newCache);
                    }
                    else
                    {
                        TransToParent(assetInfo, EnumAB.scenemodle_ab);
                    }
                }
                else
                {
                    var newBuildCache = assetInfo.m_cacheData;
                    if (newBuildCache.Equals(oldCache))
                    {
                        AddAsset(oldBuild, newCache);
                    }
                    else
                    {
                        //上面是三个并不通用的规则,这里是通用规则,如果一个文件有改变,那么谁引用它,那么谁就要重新build咯
                        TransToParent(assetInfo, assetInfo.m_cacheData.bundleId.buildType);
                    }
                }
                //以上结构不好,我就不整理了
            }
        }
        foreach (var keyvalue in m_dependsDic)
        {
            if (!m_abbuildDic.ContainsKey(keyvalue.Value.m_cacheData.bundleId))
            {
                var ab = new ABBundleInfo();
                ab.bundleId = keyvalue.Value.m_cacheData.bundleId;
                m_abbuildDic.Add(keyvalue.Value.m_cacheData.bundleId, ab);
            }
            m_abbuildDic[keyvalue.Value.m_cacheData.bundleId].fileList.Add(keyvalue.Key);
        }
    }