Skip to content

Commit

Permalink
Merge pull request #64 from JasonMa0012/2.x
Browse files Browse the repository at this point in the history
Add LwguiGradient initializers, Fix Gradient Editor time editing
  • Loading branch information
JasonMa0012 authored Sep 20, 2024
2 parents b0ea2cd + e7d0ed5 commit dcb0ad7
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
45 changes: 45 additions & 0 deletions Runtime/LwguiGradient/LwguiGradient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,51 @@ public LwguiGradient(Color[] colors, float[] times)

public LwguiGradient(List<AnimationCurve> 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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down

0 comments on commit dcb0ad7

Please sign in to comment.