void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } }
public void InitializePallets() { GameObject palletHolder = GameObject.FindGameObjectWithTag("PalletHolder"); int idx = 0; foreach (GameObject towerStat in towerStats) { TowerStats createdTowerStats = (Instantiate(towerStat) as GameObject).GetComponent<TowerStats>(); createdTowerStats.gameObject.transform.SetParent(this.errataHolder); GameObject instance; // The last one is definitely the pedestal pallet; idx += 1; if (idx == towerStats.Length) { instance = Instantiate(pedestalPallet, Vector3.zero, Quaternion.identity) as GameObject; } else { instance = Instantiate(basePallet, Vector3.zero, Quaternion.identity) as GameObject; } instance.GetComponent<TowerPallet>().ApplyStats(createdTowerStats.GetComponent<TowerStats>()); instance.transform.SetParent(palletHolder.transform); } }