public static float Resolve(UIFixedLength length, float relativeBase, float emSize, float viewportWidth, float viewportHeight) { switch (length.unit) { case UIFixedUnit.Unset: case UIFixedUnit.Pixel: return(length.value); case UIFixedUnit.Percent: return(length.value * relativeBase); case UIFixedUnit.Em: return(length.value * emSize); case UIFixedUnit.ViewportWidth: return(length.value * viewportWidth); case UIFixedUnit.ViewportHeight: return(length.value * viewportHeight); default: throw new ArgumentOutOfRangeException(); } }
public bool Equals(UIFixedLength other) { return(((float.IsNaN(value) && float.IsNaN(other.value)) || Mathf.Approximately(value, other.value)) && unit == other.unit); }