少年修仙传客户端基础资源
hch
2024-07-30 e037e701c6e97825f82fc007deb2b84a86181c61
0312 调整图集图片的加载方式
2个文件已修改
37 ■■■■■ 已修改文件
Assets/Editor/Tool/UpdateAssetBundleName.cs 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Launch/ResourcesModel.cs 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/Tool/UpdateAssetBundleName.cs
@@ -59,16 +59,16 @@
            // EditorUtility.SetDirty(importer);
        }
        allFiles = new DirectoryInfo(rootPath).GetFiles("*.png", SearchOption.AllDirectories);
        //allFiles = new DirectoryInfo(rootPath).GetFiles("*.png", SearchOption.AllDirectories);
        foreach (var file in allFiles)
        {
            var pathStringArray = file.DirectoryName.Split(Path.DirectorySeparatorChar);
            var importerPath = spriteRelativePath + Path.DirectorySeparatorChar + pathStringArray[pathStringArray.Length - 1] + Path.DirectorySeparatorChar + file.Name;
            var importer = AssetImporter.GetAtPath(importerPath);
            importer.assetBundleName = "ui/sprite/" + pathStringArray[pathStringArray.Length - 1].ToLower();
            // EditorUtility.SetDirty(importer);
        }
        //foreach (var file in allFiles)
        //{
        //    var pathStringArray = file.DirectoryName.Split(Path.DirectorySeparatorChar);
        //    var importerPath = spriteRelativePath + Path.DirectorySeparatorChar + pathStringArray[pathStringArray.Length - 1] + Path.DirectorySeparatorChar + file.Name;
        //    var importer = AssetImporter.GetAtPath(importerPath);
        //    importer.assetBundleName = "ui/sprite/" + pathStringArray[pathStringArray.Length - 1].ToLower();
        //    // EditorUtility.SetDirty(importer);
        //}
        DebugEx.Log("Sprite资源包名更新完成!");
Assets/Launch/ResourcesModel.cs
@@ -104,6 +104,8 @@
        AssetBundle spriteBundle = null;   //需要卸载
        AssetBundle prefabBundle = null;   //需要卸载
        SpriteAtlas spriteAtlas = null;
        public void Init()
        {
            //if (Application.isMobilePlatform)
@@ -170,6 +172,7 @@
            prefabBundle?.Unload(true);
            assetVersions = null;
            localAssetVersions = null;
            spriteAtlas = null;
            Debug.Log("提前ResourcesModel.Destroy资源");
        }
@@ -269,12 +272,16 @@
            }
#else
        if (spriteBundle == null)
        {
            string _path = GetAssetFilePath("builtin/sprites");
            spriteBundle = AssetBundle.LoadFromFile(_path);
        }
        sprite = spriteBundle.LoadAsset(name, typeof(Sprite)) as Sprite;
            if (spriteBundle == null)
            {
                string _path = GetAssetFilePath("builtin/sprites");
                spriteBundle = AssetBundle.LoadFromFile(_path);
            }
            if (spriteAtlas == null)
            {
                spriteAtlas = spriteBundle.LoadAsset("sprites", typeof(SpriteAtlas)) as SpriteAtlas;
            }
            sprite = spriteAtlas.GetSprite(name);
#endif
            if (sprite == null)
            {