123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using System;
- namespace UnityEngine.PostProcessing
- {
- [Serializable]
- public sealed class ColorGradingCurve
- {
- public ColorGradingCurve(AnimationCurve curve, float zeroValue, bool loop, Vector2 bounds)
- {
- this.curve = curve;
- this.m_ZeroValue = zeroValue;
- this.m_Loop = loop;
- this.m_Range = bounds.magnitude;
- }
- public void Cache()
- {
- if (!this.m_Loop)
- {
- return;
- }
- int length = this.curve.length;
- if (length < 2)
- {
- return;
- }
- if (this.m_InternalLoopingCurve == null)
- {
- this.m_InternalLoopingCurve = new AnimationCurve();
- }
- Keyframe key = this.curve[length - 1];
- key.time -= this.m_Range;
- Keyframe key2 = this.curve[0];
- key2.time += this.m_Range;
- this.m_InternalLoopingCurve.keys = this.curve.keys;
- this.m_InternalLoopingCurve.AddKey(key);
- this.m_InternalLoopingCurve.AddKey(key2);
- }
- public float Evaluate(float t)
- {
- if (this.curve.length == 0)
- {
- return this.m_ZeroValue;
- }
- if (!this.m_Loop || this.curve.length == 1)
- {
- return this.curve.Evaluate(t);
- }
- return this.m_InternalLoopingCurve.Evaluate(t);
- }
- public AnimationCurve curve;
- [SerializeField]
- private bool m_Loop;
- [SerializeField]
- private float m_ZeroValue;
- [SerializeField]
- private float m_Range;
- private AnimationCurve m_InternalLoopingCurve;
- }
- }
|