// 添加一个下载任务 public DownloadInfo DownloadInSeconds(string filename, string md5, Action <DownloadInfo> onComplete) { filename = FilePathTools.NormalizePath(filename); DownloadInfo info = new DownloadInfo(filename, md5, onComplete); pendingDownloads.Enqueue(info); return(info); }
/// <summary> /// 获取资源的相对路径,在Export基础上 /// </summary> /// <returns></returns> public static string GetShortPathRelativeExport(string fullpath) { fullpath = FilePathTools.NormalizePath(fullpath); int i = fullpath.IndexOf("Export/"); string sp = fullpath.Substring(i + 7); return(sp); }
public AssetBundleInfo GuessBundleByAssetName(string assetName) { return(_versionInfo.GuessBundleByAssetName(FilePathTools.NormalizePath(assetName.ToLower()))); }
/// <summary> /// 从编辑器里加载资源 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="name"></param> /// <returns></returns> private T LoadEditorResource <T>(string name) where T : UObject { List <string> path = new List <string>(); if (typeof(T) == typeof(Sprite)) { path.Add(name + ".png"); path.Add(name + ".jpg"); } else if (typeof(T) == typeof(Texture2D)) { path.Add(name + ".png"); path.Add(name + ".jpg"); } else if (typeof(T) == typeof(GameObject)) { path.Add(name + ".prefab"); } else if (typeof(T) == typeof(AudioClip)) { path.Add(name + ".mp3"); path.Add(name + ".wav"); path.Add(name + ".ogg"); } else if (typeof(T) == typeof(Material)) { path.Add(name + ".mat"); } else if (typeof(T) == typeof(TextAsset)) { path.Add(name + ".txt"); path.Add(name + ".json"); path.Add(name + ".xml"); } else if (typeof(T) == typeof(SpriteAtlas)) { path.Add(name + ".spriteatlas"); } //else if (typeof(T) == typeof(TMPro.TMP_FontAsset)) //{ // path.Add(name + ".asset"); //} else if (typeof(T) == typeof(Material)) { path.Add(name + ".mat"); } else if (typeof(T) == typeof(SkeletonDataAsset)) { path.Add(name + ".asset"); } foreach (string itempath in path) { string normalizepath = FilePathTools.NormalizePath(itempath); #if UNITY_EDITOR string _editorPath = FilePathTools.GetAssetEditorPath(normalizepath); UObject Obj = UnityEditor.AssetDatabase.LoadAssetAtPath(_editorPath, typeof(T)); if (Obj != null) { return((T)Obj); } #endif } return(null); }