/// <summary> /// Returns an icon that can be used for displaying a resource of the specified type. /// </summary> /// <param name="path">Path to the project library entry to display data for.</param> /// <param name="size">Size of the icon to retrieve, in pixels.</param> /// <returns>Icon to display for the specified entry.</returns> private static SpriteTexture GetIcon(string path, int size) { LibraryEntry entry = ProjectLibrary.GetEntry(path); if (entry.Type == LibraryEntryType.Directory) { return(EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.Folder, size)); } else { ResourceMeta meta = ProjectLibrary.GetMeta(path); ProjectResourceIcons icons = meta.Icons; Texture icon; if (size <= 16) { icon = icons.icon16; } else if (size <= 32) { icon = icons.icon32; } else if (size <= 48) { icon = icons.icon48; } else { icon = icons.icon64; } if (icon != null) { return(new SpriteTexture(icon)); } switch (meta.ResType) { case ResourceType.Font: return(EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.Font, size)); case ResourceType.Mesh: return(EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.Mesh, size)); case ResourceType.Texture: return(EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.Texture, size)); case ResourceType.PlainText: return(EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.PlainText, size)); case ResourceType.ScriptCode: return(EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.ScriptCode, size)); case ResourceType.SpriteTexture: return(EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.SpriteTexture, size)); case ResourceType.Shader: return(EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.Shader, size)); case ResourceType.ShaderInclude: return(EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.Shader, size)); case ResourceType.Material: return(EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.Material, size)); case ResourceType.Prefab: return(EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.Prefab, size)); case ResourceType.GUISkin: return(EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.GUISkin, size)); case ResourceType.PhysicsMaterial: return(EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.PhysicsMaterial, size)); case ResourceType.PhysicsMesh: return(EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.PhysicsMesh, size)); case ResourceType.AudioClip: return(EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.AudioClip, size)); case ResourceType.AnimationClip: return(EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.AnimationClip, size)); } } return(null); }
private static extern void Internal_GetPreviewIcons(IntPtr thisPtr, out ProjectResourceIcons icons);