// updates using new value and saved range if new value provided and no values have been removed.
 // otherwise, has to find the range by iterating through all points, which uses more processing power.
 // returns true if range was updated, false if not.
 private bool _UpdateRangeQuery(IEnumerable <Vector2> points, Func <Vector2, float> getXOrY,
                                bool pointsRemoved = true, float?newValue = null)
 {
     if ((!pointsRemoved) && (newValue != null))
     {
         if (newValue < RawMin)
         {
             _rawMin = (float)newValue;
         }
         else if (newValue > RawMax)
         {
             _rawMax = (float)newValue;
         }
         else
         {
             return(false);
         }
     }
     else // need to completely update range if a value was removed or new value is not provided
     {
         _rawMin = MathScientific.Min(points, getXOrY);
         _rawMax = MathScientific.Max(points, getXOrY);
     }
     return(true);
 }
Пример #2
0
    // finds each object in the given label container transform, and returns the one with the rect of maximum width
    private float GetMaxWidthLabel(Transform labelContainer)
    {
        List <Transform> nodes = new List <Transform>();

        foreach (Transform node in labelContainer)
        {
            nodes.Add(node);
        }
        return(MathScientific.Max(nodes, (Transform t) => t.GetChild(0).GetComponent <RectTransform>().rect.width));
    }