2015-10-16 Invoke 함수 InvokeRepeating 함수Cancel Invoke Invoke 함수 취소
1245 단어 unity
Invoke(string,float): 몇 초 후에 어떤 함수를 실행합니까? [한 번만 호출됩니다].
매개변수 설명:
string: 실행할 함수의 이름;
Float: 초, 카운트다운 시간;
void Start ()
{
Invoke("CreatBoxFun", 5f);
}
void CreatBoxFun()
{
GameObject.Instantiate(obj, new Vector3(Random.Range(-10.14f, 11.51f), 8f, Random.Range(-12.46f, 11.49f)), Quaternion.identity);
}
InvokeRepeating(string,float,float): 몇 초 [두 번째 매개 변수] 후에 어떤 함수를 실행하고 앞으로 몇 초 간격으로 [세 번째 매개 변수]마다 이 함수를 [N회 반복 호출]합니다.
매개변수 설명:
string: 실행할 함수 이름;
Float:초, 준비시간, 예열시간;
Float: 초, 중복 호출 간격;
CancelInvoke(); :이 스크립트에서 모든 Invoke 호출을 취소합니다.
public GameObject obj;
//public Transform father;
// Use this for initialization
void Start ()
{
//Invoke("CreatBoxFun", 5f);
InvokeRepeating("CreatBoxFun", 5f, 5f);
Invoke("cancelInvoke", 21f);
}
void cancelInvoke()
{
CancelInvoke();
}
void CreatBoxFun()
{
GameObject.Instantiate(obj, new Vector3(Random.Range(-10.14f, 11.51f), 8f, Random.Range(-12.46f, 11.49f)), Quaternion.identity);
}