32
30

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Unityバックグラウンドでの処理 & 動作の検出

Posted at

バックグラウンドでの処理

  • 非Active時にUnityの動作を続けるように設定する

を選択し、Run In Backgroundにチェックを入れる

Main_unity_-_DynamicPatch_-_PC__Mac___Linux_Standalone__Personal___OpenGL_4_1_.png

バックグラウンドへの移行と復帰を検知する

OnApplicationPause(bool pause)を使い、引数pauseStatusでバックグラウンドへの移行とフォアグラウンドへの復帰を判別します。

hoge.cs
	void OnApplicationPause (bool pauseStatus)
	{
		if (pauseStatus) {
			Debug.Log("applicationWillResignActive or onPause");
		} else {
			Debug.Log("applicationDidBecomeActive or onResume");
		}
	}
32
30
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
32
30

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?