Hello!!, how to access one of the child of the parents.
[29757-безымянный.png|29757]
I want to access bslider who is child of Item_bbg. Then I will access components of the bslider, as Transform.
Why not putin this item in an public GamObject and access it on start?
Because I’m instantiating the prefabs, and they are different (number of 6 different), but the bslider is the same to every of them. That’s why I can’t access it by tag or by Finding the name on start.
All I did for now is to create a function that Find all of the childrens and to find the one with the specific name .
public Transform FindChild( Transform parent, string name, SpriteRenderer _energyBarSpriteRenderer)
{
if (parent.name == name)
return parent;
Transform pTransform = parent.GetComponent<Transform> ();
foreach (Transform t in pTransform)
{
if (t.name == name) {
_energyBarSpriteRenderer = t.GetComponent<SpriteRenderer>();
print ("JORA ASTAAA EU!!!");}
}
return null;
}
But then I don’t know how to make an object or how to access this children and it’s components. I’ find him, but how to access it and to use it I don’t know (.
Access and use out of the created function.