public void Build(ModelTexture mtex) { if (mtex == null) { return; } Grid.Clear(); Grid.AddElement(Instantiate(HLine)); Variant variant = mtex.GetParent <Variant>(); foreach (ModelTexture sibling in variant.Children <ModelTexture>()) { if (sibling != mtex) { ARColorIcon icon = MakeIcon(); icon.modeltexture = sibling; icon.ColorIcon.Selected = sibling == mtex; icon.ClickBox.AddEventListener("onclick", () => { if (OnSelect != null) { OnSelect(sibling); } }); Grid.AddElement(icon); Grid.AddElement(Instantiate(HLine)); } } }
public void Build(List <ModelTexture> models) { Grid.Clear(); List <Model> list = new List <Model>(); Grid.AddElement(Instantiate(HLine)); foreach (ModelTexture modeltexture in models) { Model model = modeltexture.GetParent <Model>(); if (model != null && !list.Contains(model)) { AddModel(modeltexture, model.Name + " >"); list.Add(model); } } }
public async void Build(string title, List <Variant> variants) { if (invalid) { return; } if (!StartBuild()) { return; } AddLoadingItem(); Grid.Clear(); if (Title != null) { Title.text = title; } foreach (Variant variant in variants) { Grid.AddElement(MakeIcon(variant)); } ItemLoaded(); }
/* Buld, build's the collection page from a given root collection. * The Featured carousel is firstly made from root collection. * The following steps are then repeated: * 1. the first unused child collection with an odd number of * decendant collections is used to make a grid (inclusive * of that child). * 2. the first unused child collection with an even number of * decendant collections will be used to make a carousel * (inclusive of the child) and a grid (not including the * child). Unless collection has no decendant's. * 3. 1 and 2 are repeated until not possible then the remaining * unused child collections are used to make a grid. * * @param collection, root collection * * once loaded isLoaded set true */ public void BuildOld(Collection collection) { collection.test(); if (invalid) { Debug.Log("Invalid collection page."); return; } else if (Grid == null) { Debug.Log($"Null grid"); return; } else if (!StartBuild()) { Debug.Log("Items already being loaded."); return; } AddLoadingItem(); Grid.Clear(); Grid.AddElement(MakeFeatured(collection)); //Get size of each child collection List <Collection> children = collection.Children <Collection>(); List <int> sizes = new List <int>(); foreach (Collection child in children) { sizes.Add(child.BFS <Collection>(true).Count); } bool add = true; while (add) { add = false; for (int i = 0; i < sizes.Count; i++) { if (sizes[i] % 2 == 0) { Collection child = children[i]; Grid.AddElement(MakeGrid(child, true)); sizes.RemoveAt(i); children.RemoveAt(i); add = true; break; } } for (int i = 0; i < sizes.Count; i++) { if (sizes[i] % 2 == 1 && sizes[i] > 2) { Collection child = children[i]; Grid.AddElement(MakeCarousel(child)); Grid.AddElement(MakeGrid(child, false)); sizes.RemoveAt(i); children.RemoveAt(i); add = true; break; } } } Grid.AddElement(MakeGrid(children)); ItemLoaded(); }