public UnityButton Clone(string name, Vector3 posOffset) { UnityButton newBut = new UnityButton(); newBut.rootObj = Object.Instantiate(rootObj); newBut.rootObj.name = name; //=="" ? srcObj.name+"(Clone)" : name; newBut.Init(); newBut.rootT = newBut.rootObj.transform; newBut.rootT.SetParent(rootT.parent); newBut.rootT.localPosition = rootT.localPosition + posOffset; newBut.rootT.localScale = rootT.localScale; newBut.rootT.localRotation = rootT.localRotation; return(newBut); }
// Use this for initialization void Start() { instance = this; buttonSpawn.Init(); txtTimer.text = ""; scoreObj.SetActive(false); List <Rsc> rscList = ResourceManager.GetResourceList(); for (int i = 0; i < rscList.Count; i++) { if (i == 0) { rscObjList[i].Init(); } else { rscObjList.Add(rscObjList[0].Clone("RscObj" + i, new Vector3(i * 90, 0, 0))); } rscObjList[i].imageIcon.sprite = rscList[i].icon; } OnLife(0); OnNewWave(1); OnResourceChanged(new List <int>()); if (SpawnManager.AutoStart()) { buttonSpawn.rootObj.SetActive(false); //StartCoroutine(AutoStartTimer()); OnSpawnTimer(SpawnManager.GetAutoStartDelay()); } }