When a
UILabel contains a link such as
Click Me and the label's Alignment is set to Justified,
GetUrlAtPosition() returns null unless the click was at the very beginning of the text line containing the link and the link happened to be at the beginning of the line.
The root of the problem is in the
NGUIText.PrintExactCharacterPositions() method used internally by
GetUrlAtPosition(). That method recalculates the position of every glyph in the text and then calls
NGUIText.Align() to apply the selected alignment (
Right,
Center or
Justified). When the alignment is
Justified,
NGUIText.Align() expects its first argument, the
verts array, to contain 4 elements per index: one for each corner. However, when
NGUIText.PrintExactCharacterPositions() calls it, the array has 2 elements per index: bottom left and top right, causing the array to be incorrectly updated and calls to
NGUIText.GetExactCharacterIndex(), which depends on the array, to fail.
Note: this is with NGUI 3.7.7. See the attached patch for a partial solution.