- Home /
Hierarchy Class
Hello!
I'm trying to make a class that displays a hierarchy like unity, which listing content of a gameobject. For now, it works well if one object is contained in this gameobject. If I put a second, it ranks well below but its content ranks not !
I doubt that there is a precise method and probably different from this one! : D not bad ... : Lol: I've tried several solutions but none work.
public bool showChilds= false; public bool showOptions= false; public GUISkin HUD; private Rect menuP; public GameObject Scene;
 
               public GameObject[] emetteurs;
 void OnGUI() { GUI.skin = HUD; menuP = new Rect(100, 100, 150, 350); 
 menuP = GUI.Window(11, menuP, displaymenuP, ""); }
 void displaymenuP(int id) { 
 GUILayout.BeginArea (new Rect(20, 0, 150, 350)); 
      if(showChilds){
         if( GUI.Button(new Rect(5, 25, 142, 18), Scene.name, "hiera_ep") || GUI.Button(new Rect(0, 27, 14, 14), "", "bt_flecheO")){ showChilds = false; }
         int i =0;
         int h =0;
         foreach(Transform emetteurs in Scene.transform) {
             if(showOptions){
                 if(GUI.Button(new Rect(25, 42+i*16, 120, 18), emetteurs.name, "bt_hiera_obj2") || GUI.Button(new Rect(10, 44+i*16, 14, 14), "", "bt_flecheO")){ showOptions = false; print("Emetteurs "+emetteurs.name+" - Ref " +i);}
                 foreach(Transform options in emetteurs.transform) { 
                     if(GUI.Button(new Rect(25, 58+i*16, 120, 18), options.name, "bt_hiera_obj")){ print("Options "+options.name+" - Ref " +i); }
                     i++;
                 }
             }
             else{ 
                 if(GUI.Button(new Rect(25, 42+i*16, 120, 18), emetteurs.gameObject.name, "bt_hiera_obj2") || GUI.Button(new Rect(10, 44+i*16, 14, 14), "", "bt_flecheF")){ showOptions = true;}
             }
             i++;
         }
     }
     else
     { 
         if(GUI.Button(new Rect(5, 25, 142, 18), Scene.name, "hiera_ep") || GUI.Button(new Rect(0, 26, 14, 14), "", "bt_flecheF")){ showChilds = true;}
     }
 GUILayout.EndArea();
 } 
}
Thank you in advance for your help. i'm looking forward to read your answer
Freelax
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                