Author Topic: Set Anchor on hidden objects  (Read 1552 times)

capitalj

  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 88
    • View Profile
Set Anchor on hidden objects
« on: March 24, 2014, 11:45:56 PM »
Hi,

I'm using SetAnchor on widgets to anchor them to gameobjects. But I've noticed that if I anchor them to an object who's renderer's are disabled then the widget is positioned offscreen (transform: http://cl.ly/image/2I1N1M183t0l ) even if the object becomes visible afterwards (ie: I'm using the FOW plugin and it takes a second or so for the object to become visible as the fog is lifted from the area around it, so I set the anchor to the object and then rebuild the FOW so that it reveals the object).

-JJ

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Set Anchor on hidden objects
« Reply #1 on: March 26, 2014, 03:25:20 AM »
That seems to be a backwards way of doing it to me...

Attach a script to your FOW-effected object. Inside that script in its OnEnable, create the HUD element that you're trying to anchor. In its OnDisable, destroy the HUD element. This way the object will always control its HUD, and disabling the object will hide the HUD element as well.

capitalj

  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 88
    • View Profile
Re: Set Anchor on hidden objects
« Reply #2 on: March 26, 2014, 12:35:55 PM »
My objects aren't being disabled/enabled though, just their renderers are being hidden by the FOWRenderers script. Not sure why that would even matter to the uiwidget anchoring, shouldn't those just anchor to any gameobject even if it's an empty gameobject?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Set Anchor on hidden objects
« Reply #3 on: March 26, 2014, 07:49:54 PM »
Alright, then I don't know why this would happen. Doesn't seem to occur here when I try it with a box. With a renderer enabled or disabled it all behaves the same.