using UnityEngine;
using System.Collections;
public class Test : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
[ContextMenu("TextHave")]
public void GetUITextHave()
{
int length = GetComponentsInChildren<UILabel>(true).Length;
//true代表隱藏的物體也會被遍歷
string path;
Transform temp;
for (int i = 0; i < length; i++)
{
temp = GetComponentsInChildren<UILabel>(true)[i].transform;
path = temp.name + "/";
while (temp.parent != null)
{
temp = temp.parent;
path += temp.name + "/";
// Debug.Log(1);
}
Debug.Log(GetComponentsInChildren<UILabel>(true)[i].text + " " + path);
}
}
}