mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-25 02:10:16 +00:00
3.0 commit
This commit is contained in:
@@ -13,6 +13,17 @@ namespace XChartsDemo
|
||||
internal static class UIUtil
|
||||
{
|
||||
|
||||
public static GameObject Instantiate(GameObject clone, Transform parent)
|
||||
{
|
||||
var obj = GameObject.Instantiate(clone);
|
||||
obj.layer = LayerMask.NameToLayer("UI");
|
||||
obj.transform.SetParent(parent, true);
|
||||
obj.transform.localScale = Vector3.one;
|
||||
obj.transform.localPosition = Vector3.zero;
|
||||
obj.SetActive(true);
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static RectTransform GetRectTransform(Transform transform, string path)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
@@ -70,5 +81,17 @@ namespace XChartsDemo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetText(GameObject parent, string text, string subPath = null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(subPath))
|
||||
{
|
||||
parent.transform.Find(subPath).GetComponent<Text>().text = text;
|
||||
}
|
||||
else
|
||||
{
|
||||
parent.GetComponent<Text>().text = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user