问题描述:
我们经常遇到问题,在手机平台切换后台或者其他什么操作,导致Unity进程的抬起事件监听不到,造成比如滑条乱跑,按住特效不消失,按钮一直处于按下状态等等问题。
解决思路:
参考文章:https://www.jianshu.com/p/3a7989d1ff26
Unity有两个接口函数
OnApplicationPause
OnApplicationFocus
官方解释:
OnApplicationFocus is called when the application loses or gains focus. Alt-tabbing or Cmd-tabbing can take focus away from the Unity application to another desktop application. This causes the GameObjects to receive an OnApplicationFocuscall with the argument set to false. When the user switches back to the Unity application, the GameObjects receive an