Beispiel #1
0
        private string GetEditorAssetPath <T>(string url) where T : Object
        {
            if (url.IsEmpty())
            {
                return(string.Empty);
            }
            string u = url.ToUnixPath();

            if (u.StartsWith(Application.dataPath))
            {
                u = url.Substring(Application.dataPath.Length);
            }
            else
            {
                u = Cdn.ToRelativePath(u);
            }

            if (typeof(T) == typeof(Object))
            {
                u = FindAsset(u, ".prefab", ".asset");
            }
            else if (typeof(T).IsAssignableFrom(typeof(Texture)))
            {
                u = FindAsset(u, FileType.Image.GetExt());
            }
            else if (typeof(T).IsAssignableFrom(typeof(GameObject)))
            {
                u = FindAsset(u, FileType.Prefab.GetExt());
            }
            else if (typeof(T).IsAssignableFrom(typeof(Animation)))
            {
                u = FindAsset(u, FileType.Anim.GetExt());
            }
            else if (typeof(T).IsAssignableFrom(typeof(Material)))
            {
                u = FindAsset(u, FileType.Material.GetExt());
            }
            else if (typeof(T).IsAssignableFrom(typeof(TextAsset)))
            {
                u = FindAsset(u, FileType.Text.GetExt());
            }
            else if (typeof(T).IsAssignableFrom(typeof(AudioClip)))
            {
                u = FindAsset(u, FileType.Audio.GetExt());
            }
            else if (typeof(T).IsAssignableFrom(typeof(AssetBundle)))
            {
                u = FindAsset(u, FileTypeEx.ASSET_BUNDLE);
            }
            else
            {
                // Error Handling
                u = FindAsset(u, ".anim", ".prefab", ".mat", ".png", ".jpg", ".tga", ".bmp", ".bytes", ".txt", ".csv", ".asset");
            }
            return("Assets/" + u);
        }
Beispiel #2
0
 public bool IsCached(string url)
 {
     url = Cdn.ToRelativePath(url);
     if (url.Is(FileType.Asset))
     {
         return(FindAsset(url, ".asset", ".prefab", ".png", ".jpg", ".dds", ".tga", ".tiff", ".tif", ".psd", ".ogg", ".mp3", ".wav", ".unity", ".mat", ".anim", ".txt", ".bytes", ".csv") != null);
     }
     else
     {
         string localPath = PathUtil.Combine(Application.dataPath, url);
         return(File.Exists(localPath));
     }
 }
Beispiel #3
0
 private string ToLocalPath(string url)
 {
     return(PathUtil.Combine(Application.dataPath, Cdn.ToRelativePath(url)));
 }