Welcome,
Guest
. Please
login
or
register
.
June 04, 2023, 07:45:34 PM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Dynamically adding items to scrollview via code. How to update scrollview.
« previous
next »
Print
Pages: [
1
]
Author
Topic: Dynamically adding items to scrollview via code. How to update scrollview. (Read 2216 times)
wallabie
Full Member
Thank You
-Given: 0
-Receive: 0
Posts: 200
Dynamically adding items to scrollview via code. How to update scrollview.
«
on:
March 30, 2014, 02:39:35 AM »
Hi,
I'm trying to add items to a scrollview that has a Grid. The new items are being added by instantiating a prefab and then parenting to the Grid. The problem is that the scrollList does not update to show the new added item. I have a feeling that this is not the correct way to add items dynamically to the scrollview. What is the recommended way to do this.
This is another use case of trying to make an NGUI component data aware to dynamically changing data.
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Dynamically adding items to scrollview via code. How to update scrollview.
«
Reply #1 on:
March 30, 2014, 07:35:36 AM »
UIGrid.Reposition() must be called after adding any new children to the grid.
UIWidget.MarkParentAsChanged() must be called if you moved the widget from A to B.
Logged
wallabie
Full Member
Thank You
-Given: 0
-Receive: 0
Posts: 200
Re: Dynamically adding items to scrollview via code. How to update scrollview.
«
Reply #2 on:
March 30, 2014, 02:30:49 PM »
"UIWidget.MarkParentAsChanged() must be called if you moved the widget from A to B."
You mean when one of the items of ScrollList A is moved to ScrollList B?
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Dynamically adding items to scrollview via code. How to update scrollview.
«
Reply #3 on:
March 30, 2014, 02:45:55 PM »
That's one example, yup. If you change a transform.parent, you must notify that transform that its parent has changed -- you can use the NGUITools.MarkParentAsChanged helper function and it will do the recursive updates for you.
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Dynamically adding items to scrollview via code. How to update scrollview.