public GameObject GetBullet(Vector3 pos) // 외부에서 총알을 전달받는 위치 변수
{
GameObject requireBullet = null;
for (int i = 0; i < bullets.Count; i++) // 리스트에 보관된 총알이 있는지 다 뒤져서 가져옴
{
if (bullets[i].activeSelf == false) // 비활성화 된 총알을 찾아서 반환하는 과정
{
requireBullet = bullets[i];
break;
}
}
/* 총알을 다 쓰면 총알 재생산 */
if (requireBullet == null)
{
GameObject newBullet = Instantiate(bulletPrefab) as GameObject;
newBullet.transform.parent = transform;
bullets.Add(newBullet);
requireBullet = newBullet;
}
requireBullet.SetActive(true);
requireBullet.transform.position = pos;
return requireBullet; // 만든 변수 리턴
}
은 GetComponent<Script이름>().을 쓰면 된다.
A = string.Empty; // 스코어 점수 초기화
Build Settings > Add Open Scenes
using UnityEngine.SceneManagement;