public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); if (untintedStyle == null) { untintedStyle = new CompiledStyleDefinition(new StyleDefinition() { MaxSize = 64 }); tintedStyle = new CompiledStyleDefinition(new StyleDefinition() { MaxSize = 64 }); } var sliderRect = new Rect(position.x, position.y + 12, position.width, EditorGUIUtility.singleLineHeight); var previewArea = new Rect(position.x, sliderRect.yMax + 12, position.width, position.yMax - 24 - sliderRect.yMax); var untintedRect = new Rect(previewArea.x, previewArea.y, (previewArea.width * 0.5f) - 3.0f, previewArea.height); var tintedRect = new Rect(untintedRect.xMax + 6.0f, previewArea.y, untintedRect.width, previewArea.height); var tintStrengthProperty = property.FindPropertyRelative("tintStrength"); tintStrengthProperty.floatValue = EditorGUI.Slider(sliderRect, label, tintStrengthProperty.floatValue, 0.0f, 1.0f); if (Event.current.type == EventType.Repaint) { var tint = new ColorTint(tintStrengthProperty.floatValue * 1.0f); tintedStyle.Tint = tint.Apply(Color.white); AssetIconDrawer.DrawSprite(untintedRect, AssetIconResources.CurrentTheme.SampleImage, untintedStyle, false); AssetIconDrawer.DrawSprite(tintedRect, AssetIconResources.CurrentTheme.SampleImage, tintedStyle, false); } EditorGUI.EndProperty(); }
/// <summary> /// <para>Constructs a new instance of the <c>MethodIconProvider</c>.</para> /// </summary> /// <param name="style">A style to use to draw graphics provided by this <see cref="IIconProvider"/>.</param> /// <param name="method">A method that's invoked to provide the graphic.</param> public MethodIconProvider(CompiledStyleDefinition style, MethodInfo method) { Style = style; this.method = method; }
public FieldIconProvider(CompiledStyleDefinition style, FieldInfo field) { this.style = style; this.field = field; }