public void PrimaryGridBtn() { GridBase = GetComponent <UIGrid> (); MaxPerLine = GridBase.maxPerLine; DefaultShowIndexs = new int[] { 0, 1, 2, 3, 4, 5 }; ShowGridBtnObjs = new List <GameObject> (); PrimaryXML(); grids = SeriaOrDeSeria.DeSerialzeXML(path, typeof(GridBtn[])) as GridBtn[]; GridBtnObjs = new GameObject[grids.Length]; for (int i = 0; i < grids.Length; i++) { GameObject ob = Instantiate(GridBtnPrefab) as GameObject; ob.transform.GetChild(0).GetComponent <UITexture>().mainTexture = Resources.Load <Texture>(grids[i].ImgPath); ob.name = GridBtnPrefab.name + i.ToString(); GridBtnObjs[i] = ob; ob.transform.SetParent(DownPanelRepository.transform); ob.transform.position = Vector3.zero; ob.transform.localScale = Vector3.one; } GridBtnObjs[0].GetComponent <MyUIEventIndex>().Listener += Test1; GridBtnObjs[1].GetComponent <MyUIEventIndex>().Listener += Test2; GridBtnObjs[2].GetComponent <MyUIEventIndex>().Listener += Test3; GridBtnObjs[3].GetComponent <MyUIEventIndex>().Listener += Test4; GridBtnObjs[4].GetComponent <MyUIEventIndex>().Listener += Test5; GridBtnObjs[5].GetComponent <MyUIEventIndex>().Listener += Test6; GridBtnObjs[6].GetComponent <MyUIEventIndex>().Listener += Test7; GridBtnObjs[7].GetComponent <MyUIEventIndex>().Listener += Test8; GridBtnObjs[8].GetComponent <MyUIEventIndex>().Listener += Test9; GridBtnObjs[9].GetComponent <MyUIEventIndex>().Listener += Test10; AdjustShowGrids(0, true); }
// Use this for initialization void Start() { GridPrefab = Resources.Load <GameObject>("UIPrefabs/Grid"); uiGrid = GetComponent <UIGrid>(); taskGrid = SeriaOrDeSeria.DeSerialzeXML(AllDataPath.Instance.TaskXMLPath, typeof(TaskGrid[])) as TaskGrid[]; for (int i = 0; i < taskGrid.Length; i++) { GameObject obj = Instantiate <GameObject>(GridPrefab); obj.GetComponent <TaskGridMono>().Primary(taskGrid[i]); obj.transform.SetParent(transform); obj.transform.localPosition = Vector3.zero; obj.transform.localScale = Vector3.one; } uiGrid.repositionNow = true; }