/// <summary> /// Changes the index of the app by. /// </summary> /// <param name="index">Index.</param> /// <param name="app">App.</param> void ChangeAppByIndex(int index, App app) { appList.RemoveAt(index); appList.Insert(index, app); GameObject icon = pageChildList [index]; IconController iconController = icon.GetComponent <IconController> (); iconController.setApp(app); }
public void addPlaceholder(int pageNum, int index, Location location) { App app = new App(); app.SetIsPlaceholder(true); appList.Insert(index, app); GameObject pageLayout = pageList [pageNum]; GameObject pageChild = Instantiate(pageChildPrefab); IconController iconControl = pageChild.GetComponent <IconController> (); iconControl.setApp(app); PageLayout pageControl = pageLayout.GetComponent <PageLayout> (); iconControl.originLocation = location; pageControl.addChild(pageChild, iconControl.originLocation.position3D, new Vector2(launcherModel.itemWidth, launcherModel.itemHeight)); pageChildList.Insert(index, pageChild); }
void LoadAppIcon(int beginIndex, int endIndex) { int left = 0; int bottom = 0; int curPage = 0; int curRow = 0; int pageItemNum = launcherModel.pageItemNum; int columnNum = launcherModel.columnNum; int itemWidth = launcherModel.itemWidth; int itemHeight = launcherModel.itemHeight; int pageHeight = launcherModel.screenHeight; GameObject pageLayout = null; int appNum = endIndex; for (int i = beginIndex; i < appNum; i++) { curPage = i / pageItemNum; curRow = i % pageItemNum / columnNum; if (i % columnNum == 0) { left = 0; } else { left = itemWidth; } bottom = curRow * itemHeight; pageLayout = pageList [curPage]; GameObject pageChild = Instantiate(pageChildPrefab); IconController iconControl = pageChild.GetComponent <IconController> (); App app = appList [i]; iconControl.setApp(app); Vector3 pos3D = new Vector3(left, pageHeight - bottom - launcherModel.itemHeight, 0f); PageLayout pageControl = pageLayout.GetComponent <PageLayout> (); // Debug.Log ("LoadAppIcon left="+left+" top="+bottom); iconControl.originLocation = new Location(pageControl.pageNumber, pos3D, i); pageControl.addChild(pageChild, pos3D, new Vector2(itemWidth, itemHeight)); pageChildList.Add(pageChild); } }