Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Macro · Jul 29, 2012 at 04:39 PM · gameobjectprefabnguiscrollbar

Dynamic Scrollable List with NGUI

I am trying to make a GUI element which contains a list of inventory items, it is basically just like a big table. Now looking at the NGUI scrollbar tutorial they use a clipping area and have another panel with a scrollbar, but I cannot see how they link the scrollbar from one panel to the other panel? Is this some magic step which isn't documented too well or do you have to manually just adjust the scrollbar values based on the amount of elements within the list yourself?

Forgetting the scrollbar problem for a moment I am also a bit unsure as to how I should add each row in the list. I made a prefab which contains a dummy GameObject which then contains 4 labels which are displayed in-line. Now assuming the list container element is a panel with the UIGrid script applied (the tutorial said to include this), then I have a c# script applied which takes the list of items and tries to instantiate the (lets call it) ItemRowPrefab for each item in the list. So 10 items in the inventory should create 10 ItemRowPrefabs and then add them to the panel acting as the list container. The problem here is that to call the instantiate method for ItemRowPrefab it requires me to have an existing object to copy from, so should this just be a call to var dummyItemRowPrefab = AddComponent then pass that in as the instantiate argument for existing object? If that is the case, how do I then add the instantiated object to the panel? I can get hold of the panel but there doesn't seem to be any simple methods to AddObject(object).

Sorry for all the waffle but wanted to give as much context as possible as to what the problems are that I am facing.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image EDarkness · Nov 18, 2013 at 03:35 AM 0
Share

I'm having the same issue. No idea why this isn't a simple part of the GUI, but making a simple list is tedious. Did you ever figure out a good way to do it?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by harko12 · Jun 10, 2013 at 04:06 AM

I'm trying to make sense of this one myself. I think the magic step you're missing is that the UIPanel(clipped view) that is the panel with the grid attached has a script on it called UIDraggablePanel. In that panel there is a link to the horizontal scrollbar object. I think that script handles the updating if the scrollbar position.

As for your items, I think you're on the right track. You should make a prefab, and put all the scripts on it that it needs, then iterate through your list and create instances of it for each item that you have. You can set the parent of them as you go, I think.

I know that may not be super helpful, I'm still trying to put it all together too. There are good forums on the NGUI site (tasharen.net ?) You may want to try there.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by SteveKouts · Feb 20, 2014 at 03:02 AM

This guy shows you how to do it even though its in Russian. Its about halfway through the video where he shows you how. https://www.youtube.com/watch?v=AjzJrbiTJgE

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Source Gameobject rendered when using prefab 0 Answers

Objects flickering between dark and light 7 Answers

Get the name of an instance's prefab at runtime? 0 Answers

Create with code 2.2 pizza not shooting 1 Answer

difference between prefab and gameobject in listening event 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges