Skip to content

Commit

Permalink
curve for gradient remapping
Browse files Browse the repository at this point in the history
  • Loading branch information
andybak committed Mar 22, 2024
1 parent 087ea97 commit 02a5569
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Serialization;

[CreateAssetMenu(fileName = "AppearanceSettings", menuName = "Polyhydra/AppearanceSettings", order = 1)]
public class AppearanceSettings : ScriptableObject
Expand All @@ -16,7 +17,7 @@ public enum Mode
public Mode ColorMode;
public List<Color> ColorList;
public Gradient ColorGradient;

public AnimationCurve GradientMapping = AnimationCurve.Linear(0, 0, 1, 1);
public event Action OnSettingsChanged;

void OnEnable()
Expand All @@ -37,7 +38,9 @@ public Color[] CalculateColors()
case Mode.List:
return ColorList is { Count: 12 } ? ColorList?.ToArray() : null;
case Mode.Gradient:
return Enumerable.Range(0, 12).Select(t => ColorGradient.Evaluate(t / 12f)).ToArray();
return Enumerable.Range(0, 12).Select(t => ColorGradient
.Evaluate(GradientMapping.Evaluate(t / 12f)))
.ToArray();
default:
return null;
}
Expand Down

0 comments on commit 02a5569

Please sign in to comment.