From feca1c7994886dec467491c51cd42f9064126c52 Mon Sep 17 00:00:00 2001 From: Saas Date: Tue, 3 Mar 2026 23:44:24 +0100 Subject: [PATCH] replace HW with material instead of sprite --- Source/Editor/EditorAssets.cs | 5 +++++ Source/Editor/EditorIcons.cs | 1 - Source/Editor/GUI/Dialogs/ColorSelector.cs | 12 +++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Source/Editor/EditorAssets.cs b/Source/Editor/EditorAssets.cs index d9b3d7f18..447dc3375 100644 --- a/Source/Editor/EditorAssets.cs +++ b/Source/Editor/EditorAssets.cs @@ -69,6 +69,11 @@ namespace FlaxEditor /// public static string WindowIcon = "Editor/EditorIcon"; + /// + /// The material used for the HS color wheel. + /// + public static string HSWheelMaterial = "Editor/HSWheel"; + /// /// The window icons font. /// diff --git a/Source/Editor/EditorIcons.cs b/Source/Editor/EditorIcons.cs index 8688c502a..7da1d6fb3 100644 --- a/Source/Editor/EditorIcons.cs +++ b/Source/Editor/EditorIcons.cs @@ -134,7 +134,6 @@ namespace FlaxEditor public SpriteHandle Document128; public SpriteHandle XBoxOne128; public SpriteHandle UWPStore128; - public SpriteHandle ColorWheel128; public SpriteHandle LinuxSettings128; public SpriteHandle NavigationSettings128; public SpriteHandle AudioSettings128; diff --git a/Source/Editor/GUI/Dialogs/ColorSelector.cs b/Source/Editor/GUI/Dialogs/ColorSelector.cs index f556e8cd6..79e4029f5 100644 --- a/Source/Editor/GUI/Dialogs/ColorSelector.cs +++ b/Source/Editor/GUI/Dialogs/ColorSelector.cs @@ -12,6 +12,8 @@ namespace FlaxEditor.GUI.Dialogs /// public class ColorSelector : ContainerControl { + private const String GrayedOutParamName = "GrayedOut"; + /// /// The color. /// @@ -22,7 +24,7 @@ namespace FlaxEditor.GUI.Dialogs /// protected Rectangle _wheelRect; - private readonly SpriteHandle _colorWheelSprite; + private readonly MaterialBase _hsWheelMaterial; private bool _isMouseDownWheel; /// @@ -78,7 +80,8 @@ namespace FlaxEditor.GUI.Dialogs { AutoFocus = true; - _colorWheelSprite = Editor.Instance.Icons.ColorWheel128; + _hsWheelMaterial = FlaxEngine.Content.LoadAsyncInternal(EditorAssets.HSWheelMaterial); + _hsWheelMaterial = _hsWheelMaterial.CreateVirtualInstance(); _wheelRect = new Rectangle(0, 0, wheelSize, wheelSize); } @@ -168,9 +171,12 @@ namespace FlaxEditor.GUI.Dialogs var hsv = _color.ToHSV(); bool enabled = EnabledInHierarchy; + _hsWheelMaterial.SetParameterValue(GrayedOutParamName, enabled ? 1.0f : 0.5f); + Render2D.DrawMaterial(_hsWheelMaterial, _wheelRect, enabled ? Color.White : Color.Gray); + // Wheel float boxExpand = (2.0f * 4.0f / 128.0f) * _wheelRect.Width; - Render2D.DrawSprite(_colorWheelSprite, _wheelRect.MakeExpanded(boxExpand), enabled ? Color.White : Color.Gray); + Render2D.DrawMaterial(_hsWheelMaterial, _wheelRect, enabled ? Color.White : Color.Gray); float hAngle = hsv.X * Mathf.DegreesToRadians; float hRadius = hsv.Y * _wheelRect.Width * 0.5f; var hsPos = new Float2(hRadius * Mathf.Cos(hAngle), -hRadius * Mathf.Sin(hAngle));