Author Topic: Anchored Parent and relative Child positionen & size  (Read 3316 times)

quaigon

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Anchored Parent and relative Child positionen & size
« on: May 26, 2014, 10:41:41 AM »
problem:

i have an UITexture as parent which is always half of screensize:
Widget: BasedOnWidth
Anchors: Left -> Left, Right -> Center, Bottom -> Center, Top -> Top


Now i have some child objects (widget with colliders), which always must have the same size and position on the UITexture no matter how large the parent will be. The anchor must there for change the size and position of the children, so that always the same picture-area on the UITexture will be covered.

How can I achieve this?

thx


Edit: version 3.6.1c

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Anchored Parent and relative Child positionen & size
« Reply #1 on: May 26, 2014, 11:18:53 PM »
The scenario you described would make your UITexture a quarter of the screen size, not half (occupies the top-left quarter).

Anchor the children so that they use the UITexture as the target. For example to anchor some 100x100 sprite to a bottom left corner of the texture, anchor left to left, bottom to bottom, top to bottom, right to left. Right and top would both have offsets of +100. If you want it to be in some relative position on the texture, instead of "Target's Left" etc use "Custom" and specify your own relative 0-1 range position.

quaigon

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: Anchored Parent and relative Child positionen & size
« Reply #2 on: May 27, 2014, 07:08:42 AM »
it works. thx. i forgot the custom - option with set to current position.  :)

(and yes i meant the half of the screen width.)