/// <summary> /// 异步加载资源 /// </summary> /// <returns>返回AssetBundleRequest自行处理</returns> public AssetBundleRequest LoadAssetAsync <T>(ResourceType resType, string resName, string folder = "") where T : UnityEngine.Object { folder = folder.Length > 0 ? "/" + folder : folder; string path = AssetPath.GetResPath(true, AssetPath.StreamingAssetsPath, AssetPath.ResourcePath[resType] + folder); return(handlerDictionary[path].LoadAssetAsync <T>(resName)); }
public void UnLoadAsset(ResourceType resType, string resName, string folder = "") { folder = folder.Length > 0 ? "/" + folder : folder; string assetPath = AssetPath.GetResPath(true, AssetPath.StreamingAssetsPath, AssetPath.ResourcePath[resType] + folder); UnLoadAsset(assetPath); }
/// <summary> /// 使用资源类别和资源名称加载资源 /// folder参数用来加载UI/Sprite等有文件目录的资源 /// </summary> public T LoadAsset <T>(ResourceType resType, string resName, string folder = "") where T : UnityEngine.Object { string path = AssetPath.GetResPath(false, AssetPath.resourcePath + AssetPath.ResourcePath[resType], Path.Combine(folder, resName)); string[] resSuffix = ResourceSuffix[resType]; for (int i = 0; i < resSuffix.Length; i++) { string searchPath = path + resSuffix[i]; if (File.Exists(searchPath)) { return(LoadAsset <T>(searchPath)); } } return(null); }