Author Topic: UIPanel and Uniform Anchor  (Read 1599 times)

Vesuvian

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 32
    • View Profile
UIPanel and Uniform Anchor
« on: March 11, 2014, 02:04:35 PM »
Hey guys

I'm having trouble finding information on this.

I want to be able to set a UIPanel to Unified anchor mode and have it follow a GameObject. Is this possible?

From reading the source it looks like I need to set a clipping mode, but none of the clipping modes seem to do exactly what I need.

Thanks,
Ves

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPanel and Uniform Anchor
« Reply #1 on: March 11, 2014, 04:59:56 PM »
A UIPanel doesn't have a rectangle by default. It simply collects and draws widgets inside. Setting the clipping mode makes it have a rectangle, which makes it possible to anchor it. However if you are just trying to have it follow a target object, just use math instead.

1. Take the 3D world position of the target (transform.position).
2. Make it local to the panel's parent (panel.transform.parent.InverseTransformPoint).
3. Set the panel's localPosition to value from 2.