Ejemplo n.º 1
0
    private static bool IsBundleChanged(BundleData bundle)
    {
        var state = BundleManager.GetBuildStateOfBundle(bundle.name);

        if (state.changed)
        {
            return(true);
        }
        var extra = bundle.GetExtraData();

        if (bundle.bundleType == BundleType.Text)
        {
            //HACK:文本bundles中往往包含大量文件,所以永远重新打包
            return(true);
        }

        if (GetBundleAssetsListMD5(bundle) != state.assetListMd5)
        {
            return(true);
        }

        //判断所有涉及的文件是否有变化,如有,则需要重新打包
        foreach (var guid in extra.includeAssetGUIDs)
        {
            if (!state.assetStates.ContainsKey(guid))
            {
                return(true);
            }
            else if (BundleManager.CheckAssetModified(state.assetStates[guid]))
            {
                return(true);
            }
        }
        foreach (var guid in extra.dependGUIDs)
        {
            if (!state.assetStates.ContainsKey(guid))
            {
                return(true);
            }
            else if (BundleManager.CheckAssetModified(state.assetStates[guid]))
            {
                return(true);
            }
        }
        return(false);
    }