From e7d0ed5016cc7c50a12fcb717d13dc0458451040 Mon Sep 17 00:00:00 2001 From: Jason Ma <1312119064@qq.com> Date: Fri, 20 Sep 2024 16:13:18 +0800 Subject: [PATCH] Add LwguiGradient initializers, Fix Gradient Editor time editing --- Runtime/LwguiGradient/LwguiGradient.cs | 45 +++++++++++++++++++ .../LwguiGradientEditor.cs | 2 +- package.json | 2 +- 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/Runtime/LwguiGradient/LwguiGradient.cs b/Runtime/LwguiGradient/LwguiGradient.cs index f299c39..b45228d 100644 --- a/Runtime/LwguiGradient/LwguiGradient.cs +++ b/Runtime/LwguiGradient/LwguiGradient.cs @@ -111,6 +111,51 @@ public LwguiGradient(Color[] colors, float[] times) public LwguiGradient(List inRgbaCurves) => SetRgbaCurves(inRgbaCurves); + public static LwguiGradient white + { + get => new (); + } + + public static LwguiGradient gray + { + get => new (new []{Color.gray, Color.gray}, new []{0.0f, 1.0f}); + } + + public static LwguiGradient black + { + get => new (new []{Color.black, Color.black}, new []{0.0f, 1.0f}); + } + + public static LwguiGradient red + { + get => new (new []{Color.red, Color.red}, new []{0.0f, 1.0f}); + } + + public static LwguiGradient green + { + get => new (new []{Color.green, Color.green}, new []{0.0f, 1.0f}); + } + + public static LwguiGradient blue + { + get => new (new []{Color.blue, Color.blue}, new []{0.0f, 1.0f}); + } + + public static LwguiGradient cyan + { + get => new (new []{Color.cyan, Color.cyan}, new []{0.0f, 1.0f}); + } + + public static LwguiGradient magenta + { + get => new (new []{Color.magenta, Color.magenta}, new []{0.0f, 1.0f}); + } + + public static LwguiGradient yellow + { + get => new (new []{Color.yellow, Color.yellow}, new []{0.0f, 1.0f}); + } + #endregion public int GetValueBasedHashCode() diff --git a/UnityEditorExtension/LwguiGradientEditor/LwguiGradientEditor.cs b/UnityEditorExtension/LwguiGradientEditor/LwguiGradientEditor.cs index db06d92..0cf7630 100644 --- a/UnityEditorExtension/LwguiGradientEditor/LwguiGradientEditor.cs +++ b/UnityEditorExtension/LwguiGradientEditor/LwguiGradientEditor.cs @@ -350,7 +350,7 @@ private void OnGradientEditFieldGUI() if (_lastEditingTime != selectionInfo.selectedTime && _lastEditingTime != float.NegativeInfinity // End editing text - && (EditorGUI.IsEditingTextField() && Event.current.keyCode == KeyCode.Return + && (EditorGUI.IsEditingTextField() && Event.current.keyCode is KeyCode.Return or KeyCode.KeypadEnter // Mouse drag || !EditorGUI.IsEditingTextField() && hasChange)) { diff --git a/package.json b/package.json index d6e333b..dc9da2e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.jasonma.lwgui", - "version": "1.18.9", + "version": "1.19.0", "displayName": "LWGUI", "description": "A Lightweight, Flexible, Powerful Shader GUI System for Unity.", "keywords": [