hch
2025-12-09 c3bbfe2736a773f9f03fa25c0575608e9ee6c13c
Main/ResModule/ResManager.cs
@@ -70,7 +70,7 @@
        {typeof(Sprite), "png"},
        {typeof(Texture2D), "jpg"},
        {typeof(Texture), "jpg"},
        { typeof(Shader), "shader"},
        {typeof(Shader), "shader"},
        {typeof(TextAsset), "txt"},
        {typeof(AudioClip), "wav"},
        {typeof(Font), "ttf"},
@@ -126,8 +126,11 @@
    }
#endif
    public T LoadAsset<T> (string directory, string name, bool needExt = true) where T : UnityEngine.Object
    //needExt 是否需要函数内部添加后缀
    public T LoadAsset<T>(string directory, string name, bool needExt = true) where T : UnityEngine.Object
    {
        directory = directory.Replace("\\", "/");
        name = name.Replace("\\", "/");
        T asset = null;
        //  特殊处理 因为有一层图集的关系 directory要传入的应该是atlas的名字
        if (typeof(T) == typeof(Sprite))
@@ -143,12 +146,12 @@
                name = name.Substring(name.LastIndexOf("/") + 1);
            }
            directory = directory.Replace("\\", "/");
        }
        return LoadAssetInternal<T>(directory, name, needExt);
    }
    //needExt 是否需要函数内部添加后缀
    private T LoadAssetInternal<T>(string directory, string name, bool needExt = true) where T : UnityEngine.Object
    {
        T asset = null;
@@ -167,7 +170,7 @@
                //外部用到的自己加后缀,内部统一去除后缀名
                name = name.Substring(0, name.LastIndexOf("."));
            }
            //TODO: 临时特殊处理打包后的路径读取
            if (directory == "UI" || directory == "UIComp" || directory.StartsWith("Sprite")
            || directory == "Battle/Prefabs" || directory == "Materials")
            {
@@ -181,6 +184,10 @@
            else if (directory.Contains("Texture"))
            {
                directory = "maps/" + name;
            }
            else if (directory.Contains("Shader"))
            {
                directory = "graphic/shader";
            }
@@ -228,8 +235,12 @@
            return LoadAssetInternal<Sprite>(atlasName, spriteName);
    }
    //needExt 是否需要函数内部添加后缀
    public void LoadAssetAsync<T>(string directory, string name, Action<bool, UnityEngine.Object> callBack, bool needExt = true) where T : UnityEngine.Object
    {
        directory = directory.Replace("\\", "/");
        name = name.Replace("\\", "/");
        //  特殊处理 因为有一层图集的关系 directory要传入的应该是atlas的名字
        if (typeof(T) == typeof(Sprite))
        {