- Home /
 
I dont understand why my code is not working !?!?
 private void GetStoreManagers()
     {
         Transform viewport = ManagersPanel.transform.Find("Viewport");
         Transform content = viewport.transform.Find("Content");
         Transform children = content.transform.Find("ManagersPan");
         foreach (Transform child in children)
         {
                 Debug.Log (child.gameObject.name);
             Transform managers = child.transform.Find("Button");
             Manager storeManagers = managers.gameObject.GetComponent<Manager>();
             Managerlist.Add(storeManagers);
         }
             foreach (Manager child in Managerlist) {
             Debug.Log (child.Managercount);
             }
     }
 
               the names all match the game in unity and the objects, I am 100% sure, the problem is not the names
your "$$anonymous$$anagersPanel" looks like class name to me, rather than a variable.
Hi @mouhammadbatarni - just Debug.Log your objects - see if you get the viewport object. Then see if you get the content, then the children. You didn't either define what is not working - and what error you get.
Answer by tormentoarmagedoom · Jan 30, 2019 at 12:09 PM
Good day.
You need to debug your code if have this kind of problems. You are the onlyone that can solve them...
In addittion,
 Transform viewport = ManagersPanel.transform.Find("Viewport")
 
               ManagersPanel is a class, not an object, so it does not have childs...
Tormentoarmagedoom, it is an object, and it did have children, but yeah, I did solve this problem a long time ago, I forgot to update this post.
Your answer
 
             Follow this Question
Related Questions
Image as boundary 1 Answer
convert unity versions, 0 Answers
Issues after updating to Unity 5 1 Answer
Can't acces a variable from another script 1 Answer
I can't give damage with these scripts 2 Answers