Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: kruncher on October 20, 2013, 11:08:08 AM
Title:
Automatically scroll to end of view
Post by:
kruncher
on
October 20, 2013, 11:08:08 AM
I have a scroll panel with a vertical scrollbar which contains a simple label. The label is updated throughout game play.
How can I automatically scroll to the end as text is appended?
if
(
logLabel
.
text
==
""
)
logLabel
.
text
=
message
;
else
logLabel
.
text
+=
"
\n
"
+
message
;
// automatically scroll to end.
// Does not work :(
logScrollbar
.
value
=
1f
;
Title:
Re: Automatically scroll to end of view
Post by:
ArenMook
on
October 20, 2013, 06:08:23 PM
UIDraggablePanel.SetDragAmount
Title:
Re: Automatically scroll to end of view
Post by:
kruncher
on
October 20, 2013, 06:21:46 PM
This is almost working:
if
(
logLabel
.
text
==
""
)
logLabel
.
text
=
message
;
else
logLabel
.
text
+=
"
\n
"
+
message
;
// Automatically scroll to end.
logScroller
.
SetDragAmount
(
0
,
1
,
false
)
;
It scrolls to the entry before the latest.
Log
(
"A"
)
;
Log
(
"B"
)
;
Log
(
"C"
)
;
Log
(
"D"
)
;
// This one is at the bottom
Log
(
"E"
)
;
// Need to manually scroll to see this fellow!
Any ideas?
Title:
Re: Automatically scroll to end of view
Post by:
kruncher
on
October 20, 2013, 06:29:14 PM
Side Note: Passing "true" in to update the scrollbars causes the entire scroll panel to shift downwards (like when scroll scale is set to 0).
Title:
Re: Automatically scroll to end of view
Post by:
kruncher
on
October 20, 2013, 06:32:55 PM
Calling "UpdateScrollbars" manually seems to resolve my issue though:
// Automatically scroll to end.
logScroller
.
UpdateScrollbars
(
true
)
;
logScroller
.
SetDragAmount
(
0
,
1
,
false
)
;
Thanks for pointing me in the direction of SetDragAmount!!