concise and comprehensive
1,Invoke function
Invoke The original intention is to pray , call , stay U3D Control function call time and repeat call time in :
// Five seconds later CreateCubes method Invoke("CreateCubes",5.0f);
// Five seconds later CreateCubes, then , Call every second InvokeRepeating ("CreateCubes",5.0f,1.0f);
2,SendMessage
This method can be applied to game objects , Call the method in the script on the object
such as :
void OnTriggerEnter(Collider coll){ if(coll.gameObject.tag=="Gold"){ GameObject
.Destroy (coll.gameObject, 1); // The following two sentences have the same effect //coll.gamoObject.GetComponent< script >()
.AddScore(); coll.gameObject.SendMessage ("AddScore"); } }
3, Synergetic process
A coroutine operation is similar to creating a child thread , No more details .
// Create a process , The function is to sleep for two seconds and then print “ task 2” IEnumerator Test(){ yield return new WaitForSeconds(
2); Debug.Log(" task 2"); } // Call the orchestration method somewhere Start Coroutine(Test); // End the process Stop
Coroutine(Test);
Technology
Daily Recommendation