Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: appminis-mike on February 16, 2014, 06:58:37 PM
-
I've created a scroll view by doing the following:
1. NGUI > Create Scroll View
2. Named scroll view MyScrollView
3. On a button press, I instantiate a new ScrollItem prefab, and set it's transform.parent to MyScrollView.transform.
When I do this, my newly instantiated item is positioned at (0, -6428, 10), as are all subsequently instantiated items. Their prefabs have a position of (0, 0, 0), and even adding them to a UIGrid child of MyScrollView doesn't have any different effect (they just stack on top of each other at 0, -6428, 10).
In your instructional video here: http://www.youtube.com/watch?v=OiA4o8KqBFI, you add scripts like UIDragPanelContents, but those don't seem to exist any more. I have added UIDragScroll to my items, and the scrolling does work if I manually drag the items within the panel's viewable area, and they snap to the top of the list if I drag above it. I just can't seem to get them to start out that way (at the top of the list, as you would expect).
What might I be doing wrong?
Thank you.
-
You need to use NGUITools.AddChild(parent, prefab) to instantiate items. Look inside that function to find out why.
Don't just instantiate things in the middle of nowhere and then reparent them like you're doing. Your object layer and transform scale are likely way off as well.
-
Thank you for your response.
That helped a bit. The grid now starts at (0, 0, 0), as expected. However, the grid script itself is deactivated, and I can't activate it.
This is what I have:
MyScrollView (UIPanel, UIScrollView, UIDragScrollView, BoxCollider, RigidBody)
-- MyGrid (UIGrid)
-- List of instantiated prefabs (UIWidget, UIDragScrollView)
All of the instantiated prefabs just stack on top of each other, because the UIGrid is deactivated. How can I get this UIGrid functioning?
Thanks again!
-
GetComponent<UIGrid>().Reposition();
-
Perfect. Thanks!