private void Spawn() { var pointObj = ObjectPool.instance.GetObjectForType(pointsPrefab.name, false); var renderer = pointObj.GetComponentInChildren <SpriteRenderer> (); pointObj.SetActive(true); Vector2 spawnLocation = PointWithinBounds.GetRandomWithinBounds( renderer.sprite.bounds.size.x * renderer.gameObject.transform.localScale.x, renderer.sprite.bounds.size.y * renderer.gameObject.transform.localScale.y); pointObj.transform.position = spawnLocation; AddEventOnPointCollected(pointObj); }
private void SpawnPoint() { if (ObjectPool.instance == null) { throw new UnityException("Object pool not found"); } var projObj = ObjectPool.instance.GetObjectForType(projectileSpawnerPrefab.name, false); var renderer = projObj.GetComponentInChildren <SpriteRenderer> (); projObj.SetActive(true); Vector2 spawnLocation = PointWithinBounds.GetRandomWithinBounds( renderer.sprite.bounds.size.x * renderer.gameObject.transform.localScale.x, renderer.sprite.bounds.size.y * renderer.gameObject.transform.localScale.y); projObj.transform.position = spawnLocation; }
private void Spawn() { var enemyObj = ObjectPool.instance.GetObjectForType(enemyPrefab.name, false); var renderer = enemyObj.GetComponentInChildren <SpriteRenderer> (); enemyObj.SetActive(true); Vector2 spawnLocation = PointWithinBounds.GetRandomWithoutBounds( renderer.sprite.bounds.size.x * renderer.gameObject.transform.localScale.x, renderer.sprite.bounds.size.y * renderer.gameObject.transform.localScale.y); enemyObj.transform.position = spawnLocation; RemoveListener(); _enemyAction = enemyObj.GetComponent <ActionOnDisabled> (); AddListener(); }