- Home /
              This post has been wikified, any user with enough reputation can edit it. 
            
 
             
               Question by 
               Ochreous · Dec 22, 2014 at 12:41 AM · 
                c#gameobjecttransform  
              
 
              C# GameObjectList not Setting Parent
I'm trying to set the gameobjects of gameObjectList's parent to one gameobject. But for some reason when the script runs the gameobjects still don't have a parent. Is there something wrong with my code's logic?
 void Update(){
     for (int i = 0; i < gameObjectList.Count; i++){
         if(gameObjectList[i].transform.parent == null){
             gameObjectList[i].transform.parent = gameObject.transform;
         }
     }
 }
               Comment
              
 
               
              Try logging something if current gameobject in the for loop's parent is null. If it is successfully logging something, that means something else is wrong.
I wrote a debug.log and it does return. Any other ideas why it isn't parenting?
Are you shure, what your list is not empty?. When do you create it?
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                