少年修仙传客户端基础资源
lwb
2021-01-16 d53163a421aa411a3587d4e1f3496e12d19e5e16
9527 地图资源打包排除配置
1个文件已修改
2个文件已添加
33 ■■■■■ 已修改文件
Assets/Editor/Config/ExportMaps.txt 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/Config/ExportMaps.txt.meta 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/Tool/UpdateAssetBundleName.cs 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/Config/ExportMaps.txt
New file
@@ -0,0 +1,3 @@
//此配置是要排除的地图资源,改这个配置的时候,记得要删除原来的资源:Snxxz_Android\AssetBundles\Android\maps,再重新打包
Map001_Sjz
Map001_SjzB
Assets/Editor/Config/ExportMaps.txt.meta
New file
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ebd94328ede7d2f4ba1d87212d1683e7
TextScriptImporter:
  externalObjects: {}
  userData:
  assetBundleName:
  assetBundleVariant:
Assets/Editor/Tool/UpdateAssetBundleName.cs
@@ -373,8 +373,10 @@
public class UpdateLevelSetting
{
    static string exportMapsPath = Application.dataPath + "/Editor/Config/ExportMaps.txt";
    static string rootPath = Application.dataPath + "/Art/Maps/Scenes";
    static string assetPath = "Assets/Art/Maps/Scenes";
    static HashSet<string> exportMaps;//去除的地图列表
    public static void SetCreateRoleLevel(string pattern)
    {
@@ -395,12 +397,19 @@
    [MenuItem("程序/设置资源包名/更新Level(All) AssetBundleName")]
    public static void SetAllLevelAssetBundleName()
    {
        ReadExportConfig();
        var allFiles = new DirectoryInfo(rootPath).GetFiles("*.unity", SearchOption.TopDirectoryOnly);
        foreach (var file in allFiles)
        {
            var importerPath = assetPath + Path.DirectorySeparatorChar + file.Name;
            var importer = AssetImporter.GetAtPath(importerPath);
            importer.assetBundleName = "maps/" + Path.GetFileNameWithoutExtension(file.FullName).ToLower();
            var name = Path.GetFileNameWithoutExtension(file.FullName);
            if (exportMaps.Contains(name)) //判断这个地图是否被排除,被排除不打包
                importer.assetBundleName = "";
            else
                importer.assetBundleName = "maps/" + name.ToLower();
            // EditorUtility.SetDirty(importer);
        }
@@ -419,11 +428,23 @@
            importer.assetBundleName = "maps/textures";
            // EditorUtility.SetDirty(importer);
        }
        exportMaps?.Clear();
        exportMaps = null;
        DebugEx.Log("Level资源包名更新完成!");
        // AssetDatabase.SaveAssets();
        // AssetDatabase.Refresh();
    }
    //读取排除地图的配置
    private static void ReadExportConfig()
    {
        if (File.Exists(exportMapsPath))
        {
            var lines = File.ReadAllLines(exportMapsPath);
            exportMaps = new HashSet<string>(lines);
        }
    }
}
public class UpdateAudioSetting