Author Topic: Game World to Non UI camera view to UI camera world in pixel coordinates?  (Read 1662 times)

castor76

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
This is rather hard to explain, but I would like to

Convert 3D position into non UI Camera's view point, and then use that point in the UI camera to get the world position in the UI camera so I can make my UI element follow the object in 3D.

I have sort of got this working except that I don't want to have half pixel like situation because of the precise value I get back from all those calculation.

Is there function in NGUI that I can use to "snap" the transform value of a widget to be pixel perfect to my UI camera? My UI's setting is Flexible with pixel perfect option.


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Game World to Non UI camera view to UI camera world in pixel coordinates?
« Reply #1 on: December 09, 2015, 01:34:20 PM »
Convert the precise position into screen coordinates (camera.ViewportToScreenPoint), round the X and Y, convert back to view if you need that.