Author Topic: UIAnchor is still useful.Why UIWidget anchor target is Lost?  (Read 5061 times)

FrankYan

  • Newbie
  • *
  • Thank You
  • -Given: 6
  • -Receive: 2
  • Posts: 18
    • View Profile
UIAnchor is still useful.Why UIWidget anchor target is Lost?
« on: January 13, 2015, 08:03:12 AM »
UIAnchor is still a useful script...

In new NGUI layout system When you load a new prefab from outside(resources.load) ,if this UI prefab has UIWidget anchors, but the anchor target is not in the UI prefab(or the anchor target is not included in this UI prefab) they will be lost!I don't know why...

So I will use UIAnchor to make the right position of the screen....(this anchor is never lost)

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: UIAnchor is still useful.Why UIWidget anchor target is Lost?
« Reply #1 on: January 13, 2015, 08:16:32 AM »
A prefab that references something outside itself, will not retain its reference. This is integral to how Unity works. It works the same with UIAnchor; UIAnchor just defaults to the camera (screen) as target, where the widgetAnchor defaults to nothing. To retain it, you have to feed the anchor target into the prefab when you instantiate it.

FrankYan

  • Newbie
  • *
  • Thank You
  • -Given: 6
  • -Receive: 2
  • Posts: 18
    • View Profile
Re: UIAnchor is still useful.Why UIWidget anchor target is Lost?
« Reply #2 on: January 13, 2015, 10:53:30 PM »
Thank you for your replay.@Nicki
Sometime the UIAnchor is still useful in screen resolution, I will use UIAnchor to take Right position rather then feed the anchor target into the prefab when I instantiate it.