Skip to content

Commit

Permalink
Animation validation for color only where not all 4 channels are anim…
Browse files Browse the repository at this point in the history
…ated
  • Loading branch information
marwie committed Jan 12, 2023
1 parent e3dd445 commit 22d684b
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,21 @@ public float Evaluate(float time, int index)
return curve[index].Evaluate(time);
}

internal bool Validate()
{
if (propertyType == typeof(Color))
{
var hasEnoughCurves = curve.Count == 4;
if (!hasEnoughCurves)
{
UnityEngine.Debug.LogWarning("Animating single channels for colors is not supported. Please add at least one keyframe for all channels (RGBA): " + propertyName, target);
return false;
}
}

return true;
}

/// <summary>
/// Call this method once before beginning to evaluate curves
/// </summary>
Expand Down Expand Up @@ -900,6 +915,8 @@ private bool BakePropertyAnimation(PropertyCurve prop, float length, float bakin
times = null;
values = null;

if (!prop.Validate()) return false;

var nbSamples = Mathf.Max(1, Mathf.CeilToInt(length * bakingFramerate));
var deltaTime = length / nbSamples;

Expand Down

0 comments on commit 22d684b

Please sign in to comment.