- Home /
how to reference child in a prefab within a prefab
i need to reference a specfif child of a prefab but its in another prefab.
the prefabs name is 'animationtexturegreen' im thinking something like this public GameObject animationtexturegreen; gameobject mychild = animationtexturegreen.transform.GetChild(3).GameObject);
but that gets the child of a prefab, i need the prefab within a prefab then need to pull the child from that 2nd prefrab. i dont know how to do that and cant get google to find anything on the topic to help anymore. any help would be appreciated.
Just so we clear let me illustrate the problem you want
Parent <=== you are here
Child
------ Child <=== you want this?
im new so sorry for any confusion. but yes i can reference the prefab but i need to get the prefab of a prefab, but the only code i find references the child. is the prefab of a prefab also considered a child because i thought you would call it a prefab like
'animationtexturegreen.transform.Getprefab(3).GameObject' instead all i find on google is 'animationtexturegreen.transform.GetChild(3).GameObject'
once i reference the prefab within the prefab i need to reference a child within that prefab.
Ah okay.
So what you wanna do is if you want to go one step deeper you want to
animationtexturegreen.transform.GetChild(3).GetChild(insert index);
Your answer
Follow this Question
Related Questions
Spawn Prefabs 1 Answer
Creating an array of prefabs? 4 Answers
Replacing empty gameobjects with prefabs 3 Answers
My Health Bar Script Won't Work When I Turn My Enemy Into A Prefab 2 Answers