Author Topic: Avoiding miles-high box collider on UIDrag Panel Contents  (Read 3759 times)

Dark Acre Jack

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
  • Cyberdrunk
    • View Profile
    • Dark Acre Games
Avoiding miles-high box collider on UIDrag Panel Contents
« on: February 10, 2013, 07:49:28 AM »
Finally got wise & moved away from TextList & implemented panel clipping with UIDragPanelContents & UIDraggable Panel.

My use case: logging NPC dialog into a UILabel with UIDragPanelContents on it, that the player can go & look at from a menu, scrolling back to see all the text that's been read to them.

I'm not sure if I'm implementing this correctly, but it seems that in order for the text to scroll properly with mousewheel + mouse click n' drag, there needs to be a box collider on the UILabel that is as long/high as the eventual label will be.

Is this correct? If so, is having a say 4000 unit high box collider any cause for concern?

I have a feeling I'm missing something basic here, it just feels kludgy to have to do it this way, even if it does work.

P.S. I have the new Scroll Bar widget implemented just fine, it's just also nice for mouse users to be able to flick/scroll around in there too.

Cheers!  8)

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Avoiding miles-high box collider on UIDrag Panel Contents
« Reply #1 on: February 10, 2013, 10:00:07 AM »
Instead of having a collider directly on the label, take it out of the scrolling area and have it cover the full "viewport" of your speechbubble instead. Then you don't have to have it scroll with your text.

Hierarchy:
- ScrollView (empty gameobject)
--ScrollCollider
--ScrollPanel (this is the scrollable panel with a certain clipping area)
---Content inside the scroll (a grid, table, other fun stuff

If you need the be able to click stuff in the content, give it small colliders where it should be able to click and place it closer to the camera than the ScrollCollider.

Makes sense?

Dark Acre Jack

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
  • Cyberdrunk
    • View Profile
    • Dark Acre Games
Re: Avoiding miles-high box collider on UIDrag Panel Contents
« Reply #2 on: February 10, 2013, 03:28:48 PM »
Hey Nicki thanks for taking the time to reply.

So, not 100% sure what's happening.

Is "ScrollView" just an empty empty GO? No scripts, nothing?

I've got it set up like that:

-ScrollCollider (GO with JUST a box collider covering the visible scroll area, tagged with my NGUI layer)
--ScrollPanel (UIPanel + UIDraggable Panel)
---Content (UILabel + UIDrag Panel Contents)

With this setup now I get no interactivity from dragging/mousewheeling. My scroll bar still works though. Hm.  :-\

Any other insight? Thanks again.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Avoiding miles-high box collider on UIDrag Panel Contents
« Reply #3 on: February 10, 2013, 10:55:52 PM »
Make sure the collider is actually in front and isn't blocked by something.

Dark Acre Jack

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
  • Cyberdrunk
    • View Profile
    • Dark Acre Games
Re: Avoiding miles-high box collider on UIDrag Panel Contents
« Reply #4 on: February 11, 2013, 12:38:27 AM »
Pushing it in front blocks other colliders I have in my setup. It's just weird, I've probably got something not assigned correctly. It works fine with the "miles high" collider on it, that'll have to do for this project (time is limited) & then maybe once I'm done I can take a good look at it & put together a clear tutorial to show how to make it work correctly for my use case.

Thanks!