using UnityEngine;
using System.Collections;
namespace RootMotion.Dynamics {
///
/// A floating point value that can be used as a simple float or a weight curve evaluated by another floating point parameter.
///
[System.Serializable]
public class Weight {
///
/// Simple float value or a curve evaluated by another floating point parameter.
///
[System.Serializable]
public enum Mode {
Float,
Curve
}
///
/// Simple float value or a curve evaluated by another floating point parameter.
///
public Mode mode;
///
/// The float value.
///
public float floatValue;
///
/// The AnimationCurve.
///
public AnimationCurve curve;
// A workaround for adding tooltips to custom property drawers.
public string tooltip = "";
///
/// Initializes a new instance of the class.
///
public Weight(float floatValue) {
this.floatValue = floatValue;
}
///
/// Initializes a new instance of the class.
///
/// Float value.
/// Editor tooltip for this Weight.
public Weight(float floatValue, string tooltip) {
this.floatValue = floatValue;
this.tooltip = tooltip;
}
///
/// Gets the value. If in 'Float' mode, will return floatValue, if 'Curve' mode, will return the curve's value evaluated at 'param'.
///
public float GetValue(float param) {
switch(mode) {
case Mode.Curve: return curve.Evaluate(param);
default: return floatValue;
}
}
}
}