Author Topic: Window icon like "close,Hide,help" problem  (Read 1873 times)

sachaM

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Window icon like "close,Hide,help" problem
« on: November 23, 2012, 07:06:28 AM »
Hello,
I try to replicate the classic "top window" toolbar with the 3 icons: hide/show,close and info and ran into a positioning problem when i resize the main window: They don't stick to their locations.

TopWindow
!
+-TopWindowBackgound
+-Grid
   !--Icon1 (gameobject)
        +background
   !--Icon2
         +background
They are correctly aligned but as soon as i anchor the Grid component, all the icons jumps out of screen even if the anchor refers to topwindow background.

What i want is having them staying at the same place with the same space between them, whatever the window's size is.

I guess i missed something somewhere hehe...

thanks
 

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Window icon like "close,Hide,help" problem
« Reply #1 on: November 24, 2012, 01:47:49 AM »
I just tried it and it worked fine.
1. Created a new UI in a new scene.
2. Added a sliced sprite (called it "Sliced Sprite").
3. Beside it added a new game object with a UIAnchor on it, side: "TopRight", Widget: "Sliced Sprite".
4. Added a button child to the game object added in #3.
5. Resized the sliced sprite by dragging it -- button followed.

sachaM

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Window icon like "close,Hide,help" problem
« Reply #2 on: November 24, 2012, 02:21:32 AM »
Thanks arenmook but that's not the problem i have :

I try to have 3 icons packed together, not one, and in this case anchored both of them to the right side with offset give the unwanted behaviour. I want to have the first icon anchored to the right and the next two spaced with xx pixels from the first one, xx is a fixed space.

Maybe i should rephrase my question: Is there a way to create a container that will keep the children widgets sticked together ?

thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Window icon like "close,Hide,help" problem
« Reply #3 on: November 24, 2012, 02:23:14 AM »
You don't need a grid for that. Just add children to your anchored object, and position them yourself by adjusting their transform.