Author Topic: UI Draggable Panel with different sized objects  (Read 5350 times)

P15Studios

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
UI Draggable Panel with different sized objects
« on: November 15, 2013, 10:53:44 AM »
I'm trying to create a scrolling menu where the user can click on an object in my draggable panel and it expands, pushing the other objects below it downwards while maintaining the correct spacing between the objects.

I have the draggable panel working correctly now but I am unsure the best way to get this effect.

Thanks again!

UncleAcid

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 51
    • View Profile
Re: UI Draggable Panel with different sized objects
« Reply #1 on: November 15, 2013, 11:17:58 AM »
Sounds like the provided Quest Log example is exactly what you need to look at.

P15Studios

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: UI Draggable Panel with different sized objects
« Reply #2 on: November 15, 2013, 01:07:28 PM »
I see the example but they are using a tween scale on the object to know the height of the object. I'm using a tween position so it doesn't know the distance to space things. Also all of my sizes are all based on .something and not actual pixels so it's very hard to determine actual layouts.

I have a card that has a header, body and footer. This is stored in a prefab. In this prefab, the header is a button. On press, I tween the position of the body and the footer in the y. This moves it down and back up as I want. I have multiple of these objects in the UITable but the table doesn't react as the size of the object never changes, the elements inside just move.

Does this make sense?

I attached an Image

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UI Draggable Panel with different sized objects
« Reply #3 on: November 15, 2013, 09:43:17 PM »
Sounds like you're just missing the notification sent to the table when something changes: UITable.repositionNow = true

P15Studios

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: UI Draggable Panel with different sized objects
« Reply #4 on: November 16, 2013, 10:30:04 AM »
So far, I've done my entire UI in NGUI without touching the code. I've just been setting things up in prep for data. I looked at the TweenScale which has the UITable.repositionNow function but the TweenPosition does not. I'll go ahead and create my own mods to the position script unless I'm somehow missing it.

I've attached screens of my TweenPosition and my TweenScale. If this functionality is not in there now, I wonder if it would be a good update or if there are inherent reasons that this is bad?

P15Studios

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: UI Draggable Panel with different sized objects
« Reply #5 on: November 16, 2013, 11:43:06 AM »
So what I did is a bit of a kluge but I added an sprite that is totally transparent and put it in the back of my element and added the TweenScale script to that. Then I had that update the UITable and all works as expected. Would be nice to be able to update the table based on the position though.

Thanks for your help ArenMook and UncleAcid!