Author Topic: Setting up a basic ScrollView  (Read 3002 times)

Zwartraider

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Setting up a basic ScrollView
« on: January 25, 2014, 11:39:15 AM »
Hello,

I am having trouble setting up a basic ScrollView, like in the NGUI example scene:
- I have created an UIRoot with a ScrollView inside, the ScrollView has the UIScrollView script.
- I have added a Grid in the ScrollView.
- Within the Grid I have added a few sprites with colliders and the UIDragScrollView script attached to them, they have the ScrollView as their reference.


The setup doesn't allow me any dragging whatsoever, I have tried:

- Changing various depth values of the objects involved.
- Toggling all the settings in the drag scripts used.
- Stripping the NGUI example scene, I couldn't find major differences between my setup and the example scene.
- Using objects other than sprites. Just regular boxes with colliders. That gave a new problem because the camera wouldnt render any cubes I placed in the ScrollView.
- Setting up one or two objects in the ScrollView without a Grid involved. This still didn't work.
- I have searched on this issue, these topics offered some tips but didn't help me solve my problem:

http://www.tasharen.com/forum/index.php?topic=7026.0
http://www.tasharen.com/forum/index.php?topic=7549.msg35671#msg35671

This is how my scene looks like:



I guess it is some small oversight which has eluded me. Can anyone see what the problem could be? Thanks.

Bug5532

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: Setting up a basic ScrollView
« Reply #1 on: January 25, 2014, 11:43:02 AM »
I had this problem as well, turned out the new sprites weren't on the same layer as the gui. Clicking on the scrollview and changing the layer for all children fixed it for me :)

Zwartraider

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Setting up a basic ScrollView
« Reply #2 on: January 25, 2014, 11:54:29 AM »
I had this problem as well, turned out the new sprites weren't on the same layer as the gui. Clicking on the scrollview and changing the layer for all children fixed it for me :)

Changing the layer to Default on the scrollview and the children resulted in the camera not rendering anything.

This is the situation after changing the layers, it's also a setup without the Grid:


BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Setting up a basic ScrollView
« Reply #3 on: January 25, 2014, 12:10:31 PM »
Your GUI and everything displayed on your GUI have to be on a complete different Layer. Don't forget to uncheck that Layer from your MainCamera aswell!

Zwartraider

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Setting up a basic ScrollView
« Reply #4 on: January 25, 2014, 12:23:35 PM »
Your GUI and everything displayed on your GUI have to be on a complete different Layer. Don't forget to uncheck that Layer from your MainCamera aswell!

In my scene I have made the following changes:

- The UI Root and the camera have the Default Layer.
- The ScrollView and everything inside have a separate new Layer I made for them.
- The camera has the culling mask set to everything.

This results in the objects being drawn again. However, I am still not able to scroll.

A quick look at the NGUI example scene also shows that all objects there have an empty field for a layer. This is how I find it at default, messing around with the layers there also breaks the camera rendering.

I noticed this "null-layer" state as well on my freshly created UI elements in my own scene.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Setting up a basic ScrollView
« Reply #5 on: January 25, 2014, 03:50:49 PM »
NGUI events go to colliders. You have no colliders, so you can't get events. Select a sprite, hit ALT+SHIFT+C.

And please watch the NGUI 3.0.7 Tutorial video. It covers this, and creates a scroll view from scratch with all the necessary steps.

Zwartraider

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Setting up a basic ScrollView
« Reply #6 on: January 25, 2014, 07:19:00 PM »
NGUI events go to colliders. You have no colliders, so you can't get events. Select a sprite, hit ALT+SHIFT+C.

And please watch the NGUI 3.0.7 Tutorial video. It covers this, and creates a scroll view from scratch with all the necessary steps.

Thank you, the workflow presented in the video works indeed. I am not sure how my method of adding colliders conflicted it (I just added box colliders from the inspector instead of the right click menu) but the scrolling works just fine now.