// // Copyright (c) 2017 Anthony Marmont. All rights reserved. // Licensed for use under the Unity Asset Store EULA. See https://unity3d.com/legal/as_terms for full license information. // #if UNITY_EDITOR #pragma warning disable using System; using UnityEngine; namespace AssetIcons.Editors.Pipeline { /// /// A drawer for arbitrary objects. /// /// /// Below is an example of a graphic drawer that draws a colour based on a bool value. /// /// using AssetIcons.Editors; /// using AssetIcons.Editors.Pipeline; /// using System; /// using UnityEngine; /// /// private class BooleanGraphicDrawer : IGraphicDrawer /// { /// private bool hasValue; /// private bool lastValue; /// /// public bool CanDraw() /// { /// return hasValue; /// } /// /// public void Draw(Rect rect, bool selected, AssetIconsCompiledStyle style) /// { /// // Transform the rect of the icon in the Project window to the rect of the actual graphic. /// var drawRect = AssetIconsGUIUtility.AreaToIconRect(rect, style.MaxSize); /// /// // Using AssetIconsGUI allows us to draw stuff using the user-defined style. /// /// if (lastValue) /// { /// // Draw a green square /// AssetIconsGUI.DrawColor(drawRect, new Color32(0, 255, 0, 255), style, selected); /// } /// else /// { /// // Draw a red square /// AssetIconsGUI.DrawColor(drawRect, new Color32(255, 0, 0, 255), style, selected); /// } /// } /// /// public void SetValue(object value) /// { /// if (value != null) /// { /// lastValue = (bool)value; /// hasValue = true; /// } /// else /// { /// hasValue = false; /// } /// } /// } /// /// public interface IGraphicDrawer { /// /// Sets the current value of this graphic drawer. /// /// An that the graphic drawer should draw. void SetValue(object value); /// /// Determines whether this is usable to draw a graphic. /// /// /// true if this is valid for drawing; otherwise false. /// bool CanDraw(); /// /// Renders the last value of this . /// /// The area in which to draw. /// Whether the rendered graphic should appear selected or not. /// A style to use to render the graphic. void Draw(Rect rect, bool selected, AssetIconsCompiledStyle style); } } #pragma warning restore #endif