Author Topic: Irregular Shape UIWidget?  (Read 2189 times)

kamil.slawicki

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Irregular Shape UIWidget?
« on: January 20, 2014, 11:37:15 AM »
Hi there.

I am writing an extension tool for NGUI that will let you manipulate the four corners of the widget in order to make quadrilateral widgets of any shape. I am making a new widget type deriving from UIWidget.  I would like to know if there is any sort of callback that would let me know that the pivot of a widget has changed. I noticed that all the processing is done inside the pivot property. What I need to do is to change the position of the vertexes that describe the mesh so they would match the new pivot point. I would like to get the tool working without altering NGUI source code. Any information would be much appreciated. Thanks.
Kamil Slawicki

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Irregular Shape UIWidget?
« Reply #1 on: January 21, 2014, 01:55:33 AM »
I would strongly advise you against modifying the 4 corners of the widget. The 4 corners define the widget's area, and are meant to be a rectangle (which is why UIWidget derives from UIRect!).

If you want an irregular widget, that's fine -- it's up to you what's drawn after all. Have your custom widget define other (internal) points that reside inside the rectangle which you will then use to draw the widget in some fashion.

I recommend keeping them in 0 to 1 range as well, 0 being the bottom/left, and 1 being top/right. This way it will work properly when the widget's dimensions get resized.