| New file | 
 |  |  | 
 |  |  | using UnityEngine; | 
 |  |  | using System.Collections; | 
 |  |  | using System.Collections.Generic; | 
 |  |  | using Cysharp.Threading.Tasks; | 
 |  |  | using System; | 
 |  |  | using UnityEngine.U2D; | 
 |  |  | using LitJson; | 
 |  |  | using System.IO; | 
 |  |  | using UnityEngine.Networking; | 
 |  |  |  | 
 |  |  | #if UNITY_EDITOR | 
 |  |  | using UnityEditor; | 
 |  |  | #endif | 
 |  |  |  | 
 |  |  | using LaunchCommon; | 
 |  |  |  | 
 |  |  | public class ResManager : Singleton<ResManager> | 
 |  |  | { | 
 |  |  |      | 
 |  |  |  | 
 |  |  |     //不下载时本地安卓测试路径 | 
 |  |  |     // public string assetBundlesPath = Application.dataPath + "/../AssetBundles/Android/"; | 
 |  |  |     // public static string bytesFolderName = "logicbytes/"; | 
 |  |  |     public string StreamingAssetPath | 
 |  |  |     { | 
 |  |  |         get | 
 |  |  |         { | 
 |  |  |             return ResourcesPath.Instance.StreamingAssetPath; | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |     public string ExternalStorePath  | 
 |  |  |     { | 
 |  |  |         get | 
 |  |  |         { | 
 |  |  |             return ResourcesPath.Instance.ExternalStorePath; | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     //用于editor 下的资源路径 | 
 |  |  |     public string ResourcesOutPath  | 
 |  |  |     { | 
 |  |  |         get | 
 |  |  |         { | 
 |  |  |             return ResourcesPath.ResourcesOutPath; | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public string CONFIG_FODLER | 
 |  |  |     { | 
 |  |  |         get | 
 |  |  |         { | 
 |  |  |             return ResourcesPath.CONFIG_FODLER; | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public string ResourcesOutAssetPath | 
 |  |  |     { | 
 |  |  |         get | 
 |  |  |         { | 
 |  |  |             return ResourcesPath.ResourcesOutAssetPath; | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |      | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public void Init() | 
 |  |  |     { | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void Release() | 
 |  |  |     { | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |      | 
 |  |  |     private string GetExtension(Type type) | 
 |  |  |     { | 
 |  |  |         if (type == typeof(GameObject)) | 
 |  |  |             return ".prefab"; | 
 |  |  |         else if (type == typeof(Sprite)) | 
 |  |  |             return ".png"; | 
 |  |  |         else if (type == typeof(Texture2D)) | 
 |  |  |             return ".png"; | 
 |  |  |         else if (type == typeof(Shader)) | 
 |  |  |             return ".shader"; | 
 |  |  |         else if (type == typeof(TextAsset)) | 
 |  |  |             return ".txt"; | 
 |  |  |         else if (type == typeof(AudioClip)) | 
 |  |  |             return ".wav"; | 
 |  |  |         else if (type == typeof(Font)) | 
 |  |  |             return ".ttf"; | 
 |  |  |         else if (type == typeof(Material)) | 
 |  |  |             return ".mat"; | 
 |  |  |         else | 
 |  |  |         { | 
 |  |  |             Debug.LogErrorFormat("GetExtension() => 不支持的资源类型: {0}.", type.Name); | 
 |  |  |             return ""; | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public T LoadAsset<T> (string directory, string name) where T : UnityEngine.Object | 
 |  |  |     { | 
 |  |  |         T asset = null; | 
 |  |  | #if UNITY_EDITOR | 
 |  |  |         var path = string.Concat($"Assets/ResourcesOut/{directory}/{name}", GetExtension(typeof(T))); | 
 |  |  |         asset = UnityEditor.AssetDatabase.LoadAssetAtPath<T>(path); | 
 |  |  | #else | 
 |  |  |         if (prefabBundle == null) | 
 |  |  |         { | 
 |  |  |             // string _path = GetAssetFilePath("builtin/prefabs"); | 
 |  |  |             string _path = GetAssetFilePath($"builtin/{directory}"); | 
 |  |  |             prefabBundle = AssetBundle.LoadFromFile(_path); | 
 |  |  |         } | 
 |  |  |         asset = prefabBundle.LoadAsset(name) as t; | 
 |  |  | #endif | 
 |  |  |         if (asset == null) | 
 |  |  |         { | 
 |  |  |             Debug.LogErrorFormat("LoadBuiltInPrefab() => 加载不到资源: {0}.", name); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         return asset; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public void UnloadAsset(string assetBundleName) | 
 |  |  |     { | 
 |  |  |          | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |      | 
 |  |  |  | 
 |  |  |  | 
 |  |  | } |