コード例 #1
0
 private static extern void Internal_GetPreviewIcons(IntPtr thisPtr, out ProjectResourceIcons icons);
コード例 #2
0
        /// <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.GetProjectLibraryIcon(ProjectLibraryIcon.Folder, size));
            }
            else
            {
                ResourceMeta         meta  = ProjectLibrary.GetMeta(path);
                ProjectResourceIcons icons = meta.Icons;

                RRef <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.Value != null)
                {
                    return(new SpriteTexture(icon));
                }

                switch (meta.ResType)
                {
                case ResourceType.Font:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.Font, size));

                case ResourceType.Mesh:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.Mesh, size));

                case ResourceType.Texture:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.Texture, size));

                case ResourceType.PlainText:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.PlainText, size));

                case ResourceType.ScriptCode:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.ScriptCode, size));

                case ResourceType.SpriteTexture:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.SpriteTexture, size));

                case ResourceType.Shader:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.Shader, size));

                case ResourceType.ShaderInclude:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.Shader, size));

                case ResourceType.Material:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.Material, size));

                case ResourceType.Prefab:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.Prefab, size));

                case ResourceType.GUISkin:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.GUISkin, size));

                case ResourceType.PhysicsMaterial:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.PhysicsMaterial, size));

                case ResourceType.PhysicsMesh:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.PhysicsMesh, size));

                case ResourceType.AudioClip:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.AudioClip, size));

                case ResourceType.AnimationClip:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.AnimationClip, size));

                case ResourceType.VectorField:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.VectorField, size));
                }
            }

            return(null);
        }