Author Topic: Displaying NGUI elements relative to another camera  (Read 2614 times)

kobald

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Displaying NGUI elements relative to another camera
« on: January 25, 2014, 01:05:34 PM »
I would like to build a Google Maps-style interface. The main camera pans around a map, and the user can select map markers. Clicking a map marker will bring up an NGUI UI containing text, buttons to edit the location, etc. (And that UI is rendered directly above the map marker, based on the main camera's view.)

All of my other uses of NGUI had the NGUI camera completely separate from the main camera. Is there a way to reconcile the two? That is, have an NGUI UI be relative to another camera -- so I can easily pop up a GUI directly on top of a game object? Also, how can I get the NGUI UI to "move" along with the other camera?

(Getting the second camera to follow the other seemed problematic because of the different scales used.)

I've purchased the "HUD Text" extension, because it seems like UIFollow will be a part of the solution. But I'm not sure how to set up my objects. And at first glance it appears that HUD Text doesn't support adding more advanced UIs like buttons.

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Displaying NGUI elements relative to another camera
« Reply #1 on: January 25, 2014, 03:53:50 PM »
Part of your UI hierarchy:

GameObject (UIFollowTarget attached)
- UISprite (UIButton)
-- UILabel

And there you go, your button will follow the target, and you can still move it around as it's a child of the object that's following the target.