Whats the difference between OnApplicationFocus() and OnApplicationPause()?

一曲冷凌霜 提交于 2021-02-05 05:46:11

问题


Speaking of mobile devices, whats the difference between those two methods? If I press the home key both are called. Is there any situation when one is called and not the other?


回答1:


Since this UnityAnswer is one of the first (if not the first) to be returned on a search for OnApplicationFocus/Pause & iOS, an important update in Unity 4.6.1 has changed the behavior for iOS.

As of 4.6.1, both OnApplicationFocus and OnApplicationPause will be called in iOS.

The order is :

App initially starts:

OnApplicationFocus(true) is called

App is soft closed:

OnApplicationFocus(false) is called

OnApplicationPause(true) is called

App is brought forward after soft closing:

OnApplicationPause(false) is called

OnApplicationFocus(true) is called

Hope that helps

http://answers.unity.com/answers/970958/view.html



来源:https://stackoverflow.com/questions/31559629/whats-the-difference-between-onapplicationfocus-and-onapplicationpause

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!