// called only on start private void Treeview_FillWithItems_Rec(Treeview_DataModel father, UnitNode unit, string origin) { Treeview_DataModel son = new Treeview_DataModel { Text = unit.NAME, EntityID = unit.JCATS_ID, IsUnit = true, Health = 100, Father = father }; Dictionary <string, UnitType> unitDictionary = this.entityTypes.UnitDictionary; if (unitDictionary.ContainsKey(XmlReader.CutString(unit.NAME) + origin)) { WWW www = new WWW("file:///" + Application.dataPath + "/" + unitDictionary[XmlReader.CutString(unit.NAME) + origin].NatoSymbolFile); StartCoroutine(LoadTextureViaWWW(www, son)); } else { WWW www = new WWW("file:///" + Application.dataPath + "/" + unitDictionary["UNKNOWN" + origin].NatoSymbolFile); StartCoroutine(LoadTextureViaWWW(www, son)); } foreach (var s in unit.Systems) { son.Children.Add(new Treeview_DataModel { Text = s.JCATS_SystemCharName, EntityID = s.EntityID, IsUnit = false, Health = 0, Father = son }); // || m.NAME } father.Children.Add(son); if (unit.Subunits.Count < 0) { return; } foreach (var subunit in unit.Subunits) { Treeview_FillWithItems_Rec(son, subunit, origin); } // TODO is this correct; I moved up //father.Children.Add(son); }