UnityEditor.MathUtils.RoundBasedOnMinimumDifference C# (CSharp) Method

RoundBasedOnMinimumDifference() static private method

static private RoundBasedOnMinimumDifference ( double valueToRound, double minDifference ) : double
valueToRound double
minDifference double
return double
        internal static double RoundBasedOnMinimumDifference(double valueToRound, double minDifference)
        {
            if (minDifference == 0.0)
            {
                return DiscardLeastSignificantDecimal(valueToRound);
            }
            return Math.Round(valueToRound, GetNumberOfDecimalsForMinimumDifference(minDifference), MidpointRounding.AwayFromZero);
        }

Same methods

MathUtils::RoundBasedOnMinimumDifference ( float valueToRound, float minDifference ) : float

Usage Example

            public void SetScaleDelta(Vector3 scaleDelta, Vector3 scalePivot, Quaternion scaleRotation, bool preferRectResize)
            {
                this.SetPosition(scaleRotation * Vector3.Scale(Quaternion.Inverse(scaleRotation) * (this.position - scalePivot), scaleDelta) + scalePivot);
                Vector3 minDragDifference = ManipulationToolUtility.minDragDifference;

                if (this.transform.parent != null)
                {
                    minDragDifference.x /= this.transform.parent.lossyScale.x;
                    minDragDifference.y /= this.transform.parent.lossyScale.y;
                    minDragDifference.z /= this.transform.parent.lossyScale.z;
                }
                Quaternion ownRotation  = (!Tools.rectBlueprintMode || !InternalEditorUtility.SupportsRectLayout(this.transform)) ? this.rotation : this.transform.parent.rotation;
                Quaternion refAlignment = this.GetRefAlignment(scaleRotation, ownRotation);

                scaleDelta = refAlignment * scaleDelta;
                scaleDelta = Vector3.Scale(scaleDelta, refAlignment * Vector3.one);
                if (preferRectResize && this.rectTransform != null)
                {
                    Vector2 vector = this.sizeDelta + Vector2.Scale(this.rect.size, scaleDelta) - this.rect.size;
                    vector.x = MathUtils.RoundBasedOnMinimumDifference(vector.x, minDragDifference.x);
                    vector.y = MathUtils.RoundBasedOnMinimumDifference(vector.y, minDragDifference.y);
                    this.rectTransform.sizeDelta = vector;
                    if (this.rectTransform.drivenByObject != null)
                    {
                        RectTransform.SendReapplyDrivenProperties(this.rectTransform);
                    }
                }
                else
                {
                    this.transform.localScale = Vector3.Scale(this.scale, scaleDelta);
                }
            }
All Usage Examples Of UnityEditor.MathUtils::RoundBasedOnMinimumDifference