using UnityEngine;
using System.Collections;
using System;
using UnityEngine.UI;
public class QuickFindChildAndComponent : MonoBehaviour {
// Use this for initialization
void Start()
{
Debug.Log(ToHaveComponents(transform, "C", typeof(Rigidbody)));
Debug.Log(ToHaveComponents(transform, "D", typeof(Text)));
}
public Component ToHaveComponents(Transform b, string name, Type type)
{
Transform t = FindTransform(b, name);
return t.GetComponent(type.Name);
}
public Transform FindTransform(Transform b, string name)
{
foreach (Transform i
using System.Collections;
using System;
using UnityEngine.UI;
public class QuickFindChildAndComponent : MonoBehaviour {
// Use this for initialization
void Start()
{
Debug.Log(ToHaveComponents(transform, "C", typeof(Rigidbody)));
Debug.Log(ToHaveComponents(transform, "D", typeof(Text)));
}
public Component ToHaveComponents(Transform b, string name, Type type)
{
Transform t = FindTransform(b, name);
return t.GetComponent(type.Name);
}
public Transform FindTransform(Transform b, string name)
{
foreach (Transform i