using System; namespace UnityEngine.Animations.Rigging { /// /// Provides an accessor to a Transform component reference. /// public interface ITransformProvider { /// /// Reference to a Transform component. /// Transform transform { get; set; } } /// /// Provides an access to a weight value. /// public interface IWeightProvider { /// /// Weight. This is a number in between 0 and 1. /// float weight { get; set; } } /// /// Tuple of a Reference to a Transform component and a weight number. /// See also and . /// [Serializable] public struct WeightedTransform : ITransformProvider, IWeightProvider, IEquatable { /// Reference to a Transform component. public Transform transform; /// Weight. This is a number be in between 0 and 1. public float weight; /// /// Constructor. /// /// Reference to a Transform component. /// Weight. This is a number in between 0 and 1. public WeightedTransform(Transform transform, float weight) { this.transform = transform; this.weight = Mathf.Clamp01(weight); } /// /// Returns a WeightedTransform object with an null Transform component reference and the specified weight. /// /// Weight. This is a number in between 0 and 1. /// Returns a new WeightedTransform public static WeightedTransform Default(float weight) => new WeightedTransform(null, weight); /// /// Compare two WeightedTransform objects for equality. /// /// A WeightedTransform object /// Returns true if both WeightedTransform have the same values. False otherwise. public bool Equals(WeightedTransform other) { if (transform == other.transform && weight == other.weight) return true; return false; } /// Transform ITransformProvider.transform { get => transform; set => transform = value; } /// float IWeightProvider.weight { get => weight; set => weight = Mathf.Clamp01(value); } } }