Example #1
0
        /// <summary>
        /// <para>Paints the item in the project window.</para>
        /// </summary>
        /// <param name="guid">The GUID of the asset to check.</param>
        /// <param name="rect">The Rect in which the item is drawn.</param>
        private static void ItemOnGUI(string guid, Rect rect)
        {
            if (Event.current.type != EventType.Repaint || string.IsNullOrEmpty(guid))
            {
                return;
            }

            if (!AssetIconsPreferences.Enabled.Value)
            {
                return;
            }

            var assetTarget = pipeline.AssetTargets.GetOrCreateFromGuid(guid);

            if (string.IsNullOrEmpty(assetTarget.Extension))
            {
                return;
            }

            if (assetTarget.Extension == ".asset")
            {
                if (assetTarget.Drawer != null)
                {
                    if (assetTarget.Drawer.CanDraw())
                    {
                        var backgroundRect = AssetIconsGUIUtility.AreaToIconRect(rect, 128);
                        AssetIconsGUI.DrawBackground(backgroundRect);

                        assetTarget.Drawer.Draw(rect, assetTarget.IsSelected);
                    }
                }
            }
            else if (AssetIconsPreferences.DrawGUIStyles.Value && assetTarget.Extension == ".guiskin")
            {
                var obj = assetTarget.ObjectReference;
                if (obj is GUISkin)
                {
                    rect = AssetIconsGUIUtility.AreaToIconRect(rect);
                    AssetIconsGUI.DrawBackground(rect);

                    var skin = (GUISkin)obj;
                    skin.box.Draw(rect, new GUIContent("Style"), 0, assetTarget.IsSelected);
                }
            }
            else
            {
                var icon = AssetIconsPreferences.TypeIcons[assetTarget.Extension];
                if (icon != null && icon.ObjectReference != null && icon.GraphicDrawer != null)
                {
                    if (icon.GraphicDrawer.CanDraw())
                    {
                        AssetIconsGUI.DrawBackground(rect);

                        icon.GraphicDrawer.Draw(rect, assetTarget.IsSelected, AssetIconsCompiledStyle.Default);
                    }
                }
            }
        }
Example #2
0
            public void Draw(Rect rect, bool selected, AssetIconsCompiledStyle style)
            {
                var drawRect = AssetIconsGUIUtility.AreaToIconRect(rect, style.MaxSize);

                if (currentValue != null && currentValue.box != null)
                {
                    currentValue.box.Draw(rect, text, 0, selected);
                }
            }
            public void Draw(Rect rect, bool selected, AssetIconsCompiledStyle style)
            {
                var drawRect = AssetIconsGUIUtility.AreaToIconRect(rect, style.MaxSize);

                if (currentValue != null)
                {
                    var col = AssetIconsGUI.BackgroundColor;
                    col = new Color(col.r, col.g, col.b, 0);

                    var setup = new AssetIconsCameraSetup()
                    {
                        BackgroundColor       = col,
                        TransparentBackground = true,
                        Orthographic          = style.Projection == IconProjection.Orthographic,

                        PreviewDirection = new Vector3(-1.0f, -1.0f, -1.0f)
                    };

                    var thumbnail = AssetIconsRenderCache.GetTexture(setup, currentValue);

                    AssetIconsGUI.DrawTexture(rect, thumbnail, style, selected);
                }
            }
            public void Draw(Rect rect, bool selected, AssetIconsCompiledStyle style)
            {
                var drawRect = AssetIconsGUIUtility.AreaToIconRect(rect, style.MaxSize);

                AssetIconsGUI.DrawColor(drawRect, color, style, selected);
            }
            public void Draw(Rect rect, bool selected, AssetIconsCompiledStyle style)
            {
                var drawRect = AssetIconsGUIUtility.AreaToIconRect(rect, style.MaxSize);

                AssetIconsGUI.DrawTexture(drawRect, currentValue, style, selected);
            }