unity, iOS下画面错乱解法
unity版本号为5.1.1f1 Personal
在ipod5,系统为iOS7.1上测试。发现下面两种出现画面错乱的问题:
一,退后台在返回前台时画面发生错乱(错乱持续一两秒,然后变为正常)。
二,当弹出iOS原生对话框时画面发生错乱(关闭对话框后恢复正常)。
做了各种尝试,最后终于找到了解决办法:
在生成的xcode工程中找到UnityAppController.mm,将applicationWillResignActive函数中的下面一段代码注释掉:
// Force player to do one more frame, so scripts get a chance to render custom screen for minimized app in task manager.
// NB: UnityWillPause will schedule OnApplicationPause message, which will be sent normally inside repaint (unity player loop)
// NB: We will actually pause after the loop (when calling UnityPause).
UnityWillPause();
[self repaint];
UnityPause(1);
_snapshotView = [self createSnapshotView];
if(_snapshotView)
{
[_window addSubview:_snapshotView];
[_window bringSubviewToFront:_snapshotView];
}
即:
=>