- Home /
Retrieving GameObjects from a Prefab
Hello,
In my game I have prefabs that are made from several gameobjects.
Is there a way to, after instantiating the prefab, to access all of the gameobjects in the prefab, or can I only access them together?
Thank you!
Answer by Sisso · Jul 07, 2014 at 07:29 PM
I recommed to take some time in docs trygint to understand all the differente way to "navigate" between objects, components and transform hierarchi.
Another interesting ways:
http://docs.unity3d.com/ScriptReference/GameObject.GetComponentInChildren.html
http://docs.unity3d.com/ScriptReference/GameObject.Find.html
For example, the code below find all Transform in all childrens.
Transform[] allchildrentransform = gameObject.GetComponentsInChildre<Transform>();
Your answer
Follow this Question
Related Questions
gameObject are not referenced 2 Answers
[Solved]Instantiating prefab from a script and destroy it from another one 2 Answers
Assign an instantiated GameObject? 1 Answer
Instantiate A Prefab 1 Answer
Prefab Losing Target Transform 0 Answers