public void SpawnUnit(GameObject _Unit) { if (PopulationManager.IncPop()) { Vector2 spawnPos = (Random.insideUnitCircle.normalized * transform.localScale.x); GameObject newUnit = Instantiate(_Unit, new Vector3(spawnPos.x + transform.position.x, _Unit.transform.position.y, spawnPos.y + transform.position.z), _Unit.transform.rotation) as GameObject; newUnit.GetComponent <Unit>().Destination = SpawnLocation; } }
public override void Start() { PopulationManager.IncPop(); UnitUI = GameObject.FindWithTag("UnitUI"); Debug.Log(UnitUI + " yeah"); UnitUI.gameObject.SetActive(Selected); Building0 = UnitUI.GetComponent <UIWrapper>().Button0; Building0.onClick.AddListener(delegate { SpawnUnit(building0); }); Building1 = UnitUI.GetComponent <UIWrapper>().Button1; Building1.onClick.AddListener(delegate { SpawnUnit(building1); }); base.Start(); }