using LitJson; using System.Collections; using System.Collections.Generic; using System.IO; #if UNITY_EDITOR using UnityEditor; #endif using UnityEngine; using WK.Data; namespace WK { public class ResourceManager : Singleton { // 资源根目录是Assets/Bundle/,后续可能会把部分资源移动到streamingAssets目录 public const string kAssetRoot = "Assets/Bundle/"; public T LoadAsset(string relativePath) where T : UnityEngine.Object { #if UNITY_EDITOR string path = kAssetRoot + relativePath; T obj = AssetDatabase.LoadAssetAtPath(path, typeof(T)) as T; return obj; #else return null ; #endif } public T LoadAssetFullPath(string fullPath) where T : UnityEngine.Object { #if UNITY_EDITOR string path = fullPath; T obj = AssetDatabase.LoadAssetAtPath(path, typeof(T)) as T; return obj; #else return null ; #endif } /// /// 根据filekey读资源 /// /// /// /// public T LoadFile(string fileKey) where T : UnityEngine.Object { FileDescriptor file = DataManager.Instance.GetFile(fileKey); if (file == null) return default(T); if(file.root == FileRoot.Bundle) { #if UNITY_EDITOR string tmp = kAssetRoot + file.path; T obj = AssetDatabase.LoadAssetAtPath(tmp, typeof(T)) as T; return obj; #endif } return null; //else if(file.root == FileRoot.Persistent) //{ // string tmp = Application.persistentDataPath + "/" + file.path; //} //else if(file.root == FileRoot.Streaming) //{ //} } } }