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 AddModel(ModelTexture modeltexture, string title) { GameObject textGO = MakeText(title); ClickBox clickBox = textGO.GetComponent <ClickBox>(); clickBox.AddEventListener("onclick", () => { if (OnSelect != null) { OnSelect(modeltexture); } }); Grid.AddElement(textGO); Grid.AddElement(Instantiate(HLine)); }
/* MakeGrid, makes an instance of the GridPrefab and fills * it with icons made from the given list of collections * * @param collections, to make icons. * * @return the new grid's gameObject */ GameObject MakeGrid(List <Collection> collections) { if (collections == null) { return(null); } // Load first icon GameObject GridGO = Instantiate(GridPrefab); FlexGrid grid = GridGO.GetComponent <FlexGrid>(); foreach (Collection collection in collections) { grid.AddElement(MakeIcon(collection)); } return(GridGO); }
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(); }