// 子オブジェクト全検索 // TODO: シングルトンでオブジェクトオペレーターにまとめる private GameObject SearchHandObject(string objName) { List <GameObject> list = GameObjectOperator.GetAll(this.gameObject); for (int i = 0; i < list.Count; i++) { if (list[i].name == objName) { return(list[i]); } } // Debug.Log("[" + objName + "] は見つかりませんでした"); return(null); }
public static T GetComponentInChildren <T>(GameObject parent) where T : Component { Transform fatherTran = parent.transform; int childCount = fatherTran.childCount; for (int i = 0; i < childCount; i++) { Transform childTran = fatherTran.GetChild(i); if (childTran.GetComponent(typeof(T)) != null) { return(childTran.GetComponent(typeof(T)) as T); } else { Component t = GameObjectOperator.GetComponentInChildren <T>(childTran.gameObject); if (t != null) { return(t as T); } } } return(null); }