You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
790 B
29 lines
790 B
using UnityEngine;
|
|
using System.Collections;
|
|
using UnityEngine.UI;
|
|
|
|
public static class UIHelper
|
|
{
|
|
public static void AddScrollText(Text prefab, RectTransform contentRoot, string text, MScrollRect scrollRect)
|
|
{
|
|
if (contentRoot == null)
|
|
return;
|
|
|
|
var listItem = GameObject.Instantiate<Text>(prefab, contentRoot, false);
|
|
listItem.text = text;
|
|
|
|
if (scrollRect != null && scrollRect.isActiveAndEnabled)
|
|
scrollRect.StartCoroutine(ScrollToBottom(scrollRect));
|
|
}
|
|
|
|
public static IEnumerator ScrollToBottom(MScrollRect scrollRect)
|
|
{
|
|
yield return null;
|
|
|
|
if (scrollRect != null && scrollRect.isActiveAndEnabled && !scrollRect.isDrag)
|
|
scrollRect.normalizedPosition = new Vector2(0, 0);
|
|
}
|
|
}
|
|
|
|
|