public static T FirstDescendantComponent <T>(this MonoBehaviour v, string name) where T : Component { GameObject obj = v.FirstDescendant(name); if (obj == null) { return(null); } return(obj.GetComponent <T>()); }