Author Topic: UIScroll View problems  (Read 4196 times)

johnnydj

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
UIScroll View problems
« on: May 09, 2014, 05:16:25 AM »
As you can see in the bellow images, I have an inventory list on the side of the screen which is scrollable vertically.
At the bottom of the list I also have a button which collapses and expands the inventory list.
The way I have it setup now is that the collapse button is part of the Grid so it goes up and down with the scrolling list, which is fine until I scroll down, then my button disappears.
Is there a way do a check on that button if it hits the edge of the ScrollView, to stop going further down?

I also tried to put the button separate, out of the Grid list, so it doesn't move with the buttons, but the problem is if I remove items from my list, when my list shrinks the button remains on the bottom.
Again, is it possible to check if the list is shrinked and somehow move the button further up?






ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIScroll View problems
« Reply #1 on: May 09, 2014, 06:00:49 AM »
Don't make this button a part of the list. Make it external, in a different panel that sits on top of the scroll view like so:

UIRoot
- Scroll View (depth 1)
-- Scroll view's content, grid etc
- UIPanel (depth 2)
-- Your button

For determining the position... it would be math. No shortcut here. Although if you know the position of the first object and the last object in the grid, you can use their positions. Use UIPanel's IsVisible(pos) function to determine if the point you want is visible or not. If visible, position your button there. If not, position it at the top or bottom.

johnnydj

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: UIScroll View problems
« Reply #2 on: May 09, 2014, 06:26:06 AM »
thanks for the reply, sounds good.
1 more question. if I have an Item which is not yet in the inventory, I can go ahead and drag it into the inventory, but how could I make it to go to the inventory by clicking it?
I tried to tween it to the inventory, but I think I would need to call some function in order to register it into the scroll view.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIScroll View problems
« Reply #3 on: May 09, 2014, 06:46:25 AM »
Look at the drag & drop example and how it releases the item there, making it return to the scroll view by simply re-adding it underneath the grid object. Grid is set to animate smoothly, so it tweens the object into place automatically.

johnnydj

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: UIScroll View problems
« Reply #4 on: May 09, 2014, 06:50:19 AM »
I looked at it but it has a parameter also:
protected override void OnDragDropRelease (GameObject surface)

If I do: protected override void OnClick(GameObject surface)
I get an error: Assets/NGUI/Examples/Scripts/Other/ExampleDragDropItem.cs(50,29): error CS0115: `ExampleDragDropItem.OnClick(UnityEngine.GameObject)' is marked as an override but no suitable method found to override

johnnydj

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: UIScroll View problems
« Reply #5 on: May 09, 2014, 07:16:27 AM »
never mind my last question :)
I managed to make it work :) thanks for your help Aren!