1. 程式人生 > >How do I pause my game?

How do I pause my game?

Object[] objects =FindObjectsOfType(typeof(GameObject));foreach(GameObject go in objects){
        go.SendMessage("OnPauseGame",SendMessageOptions.DontRequireReceiver);}

And to resume call OnResumeGame on all objects.

A basic script with movement in the Update() could have something like this:

protected
bool paused;voidOnPauseGame(){         paused =true;}voidOnResumeGame(){         paused =false;}voidUpdate(){if(!paused){// do movement}}