Skip to content

Commit 815c5bb

Browse files
Nicholas Ventimigliacopybara-github
authored andcommitted
Updated scrolling logic in the sample.
PiperOrigin-RevId: 964218290
1 parent ec5da52 commit 815c5bb

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

samples/HelloWorld/Assets/Scripts/Utility/StatusText.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,23 @@ namespace GoogleMobileAds.Samples.Utility
1212
[AddComponentMenu("GoogleMobileAds/Samples/Utility/StatusText")]
1313
public class StatusText : Text
1414
{
15-
private SynchronizationContext _synchronizationContext;
1615
private const int MAX_LINES = 25; // Adjust this value as needed
17-
private List<string> _lines = new List<string>();
1816
private Regex _colorTagRegex = new Regex(@"<color=[^>]+>|</color>");
17+
private SynchronizationContext _synchronizationContext;
18+
private ScrollRect _scrollRect;
19+
private List<string> _lines = new List<string>();
1920

2021
protected override void Awake()
2122
{
2223
base.Awake();
2324

2425
if (Application.isPlaying)
2526
{
27+
verticalOverflow = VerticalWrapMode.Overflow;
2628
supportRichText = true;
2729
text = string.Empty;
2830
_synchronizationContext = SynchronizationContext.Current;
31+
_scrollRect = GetComponentInParent<ScrollRect>();
2932
Application.logMessageReceivedThreaded += OnLogMessageReceivedThreaded;
3033
}
3134
}
@@ -68,6 +71,16 @@ private void OnLogMessageReceivedThreaded(string logString, string stackTrace, L
6871
RemoveOldestLines();
6972
}
7073
text = string.Join("", _lines);
74+
75+
if (_scrollRect == null)
76+
{
77+
_scrollRect = GetComponentInParent<ScrollRect>();
78+
}
79+
if (_scrollRect != null)
80+
{
81+
Canvas.ForceUpdateCanvases();
82+
_scrollRect.verticalNormalizedPosition = 0f;
83+
}
7184
}, this);
7285
}
7386

0 commit comments

Comments
 (0)