Search Unity

Getting position where border of a 9-sliced sprite ends

Discussion in 'UGUI & TextMesh Pro' started by ferretnt, Oct 12, 2018.

  1. ferretnt

    ferretnt

    Joined:
    Apr 10, 2012
    Posts:
    412
    Suppose I have a UIImage referencing a 9-sliced sprite in which is really a thick frame of a button/etc. I want to position a child object so that it precisely covers the centre rectangle of the 9-sliced sprite. How can I compute the extents of the centre sub-rect of the 9-sliced sprite in Canvas space so I can position the child element?