Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions samples/HelloWorld/Assets/Scripts/Utility/StatusText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ namespace GoogleMobileAds.Samples.Utility
[AddComponentMenu("GoogleMobileAds/Samples/Utility/StatusText")]
public class StatusText : Text
{
private SynchronizationContext _synchronizationContext;
private const int MAX_LINES = 25; // Adjust this value as needed
private List<string> _lines = new List<string>();
private Regex _colorTagRegex = new Regex(@"<color=[^>]+>|</color>");
private SynchronizationContext _synchronizationContext;

private ScrollRect _scrollRect;
private List<string> _lines = new List<string>();

protected override void Awake()
{
Expand All @@ -25,14 +26,36 @@ protected override void Awake()
if (Application.isPlaying)
{
verticalOverflow = VerticalWrapMode.Overflow;
maskable = true;
supportRichText = true;
text = string.Empty;
_synchronizationContext = SynchronizationContext.Current;
_scrollRect = GetComponentInParent<ScrollRect>();
EnsureMask();
Application.logMessageReceivedThreaded += OnLogMessageReceivedThreaded;
}
}

private void EnsureMask()
{
GameObject target = null;
if (_scrollRect != null && _scrollRect.viewport != null)
{
target = _scrollRect.viewport.gameObject;
}
else if (transform.parent != null)
{
target = transform.parent.gameObject;
}

if (target != null &&
target.GetComponent<Mask>() == null &&
target.GetComponent<RectMask2D>() == null)
{
target.AddComponent<RectMask2D>();
}
}

protected override void OnDestroy()
{
base.OnDestroy();
Expand Down Expand Up @@ -75,6 +98,7 @@ private void OnLogMessageReceivedThreaded(string logString, string stackTrace, L
if (_scrollRect == null)
{
_scrollRect = GetComponentInParent<ScrollRect>();
EnsureMask();
}
if (_scrollRect != null)
{
Expand Down