FairyGUI.InputTextField.UpdateSelection C# (CSharp) Method

UpdateSelection() private method

private UpdateSelection ( TextField cp ) : void
cp TextField
return void
        void UpdateSelection(TextField.CharPosition cp)
        {
            TextField.CharPosition start = (TextField.CharPosition)_selectionStart;
            if (start.caretIndex == cp.caretIndex)
            {
                _selectionShape.Clear();
                return;
            }

            if (start.caretIndex > cp.caretIndex)
            {
                TextField.CharPosition tmp = start;
                start = cp;
                cp = tmp;
            }

            Vector2 v1 = GetCharLocation(start);
            Vector2 v2 = GetCharLocation(cp);

            List<Rect> rects = _selectionShape.rects;
            if (rects == null)
                rects = new List<Rect>(2);
            else
                rects.Clear();
            textField.GetLinesShape(start.lineIndex, v1.x - textField.x, cp.lineIndex, v2.x - textField.x, false, rects);
            _selectionShape.rects = rects;
            _selectionShape.xy = textField.xy;
        }