Can i find gameObject by name?

if object A is a child of object B and B have script on it,
how can i SetActive object A in this script.

i tried
A = GameObject.Find (“A”);
A.SetActive (false);

but it is not working and i have nullReference error

well there are two methods for this

  1. Your method is not wrong, it should work perfectly but the reason you are getting error is that maybe you are running this code in Update and if noting is assigned to A and you try to fetch it then it will show error. so its better to be sure with if(A != null){ A.setActive(false);}
  2. Second method is to get child A = B.transform.getchild(the index at which gameobject is child); and then A.setActive(false);