- Home /
Question by
AdanisLogan · Dec 15, 2017 at 12:00 PM ·
parentingscriptingproblem
How can I access object's children from other object?
Hi! I'm quite new to coding so maybe its a dumb question but I have a problem accessing child in different object than the one with the script. I have something like this:
public class gameManagerScript : MonoBehaviour {
public GameObject podsumowanieStatystyk;
public void Potwierdzenie ()
{
podsumowanieStatystyk.transform.GetChild (0).gameObject.SetActive (true);
}
}
Of course I have the object dragged in space for podsumowanieStatystyk game object. Can you tell me what I did wrong here?
Comment
Answer by Ginxx009 · Dec 15, 2017 at 12:29 PM
public class gameManagerScript : MonoBehaviour {
public GameObject podsumowanieStatystyk;
public void Potwierdzenie ()
{
podsumowanieStatystyk.GetComponent<nameofthescript>().SetActive(true);
}
}
As i understand your concern its more like this?
Your answer
Follow this Question
Related Questions
finding an object with tag, out of a few objects that are in array 1 Answer
Picking up and dropping objects with parenting 1 Answer
local space and rotation issues 1 Answer
Can a Gameobject that is controlled by Animator be dragged by a non animator controlled object 1 Answer
check a object is parent or not? 1 Answer