ios语音输入崩溃-阿里云开发者社区

开发者社区> 开发与运维> 正文
登录阅读全文

ios语音输入崩溃

简介:   游戏中任何可以输入的地方,只要调用语音输入,必然会导致app崩溃,解决方法如下:   ok, so essentially the gist of it is that siri wants gl context and to be rendered alongside your view.

  游戏中任何可以输入的地方,只要调用语音输入,必然会导致app崩溃,解决方法如下:

  ok, so essentially the gist of it is that siri wants gl context and to be rendered alongside your view. So you need to play nice with it.
first of all in Classes/Unity/EAGLContextHelper.h
add forward declaration for 

struct UnityDisplaySurfaceBase;

and then inside class EAGLContextSetCurrentAutoRestore add constructor:

EAGLContextSetCurrentAutoRestore(UnityDisplaySurfaceBase* surface);

so it looks like that

struct UnityDisplaySurfaceBase;
<...>
class
EAGLContextSetCurrentAutoRestore
{
public:
   EAGLContext* old;
   EAGLContext* cur;
 
   EAGLContextSetCurrentAutoRestore(EAGLContext* cur);
   EAGLContextSetCurrentAutoRestore(UnityDisplaySurfaceBase* surface);
   ~EAGLContextSetCurrentAutoRestore();
};

then in Classes/Unity/EAGLContextHelper.mm
add

#include "UnityRendering.h"

and implementation for new ctor

EAGLContextSetCurrentAutoRestore::EAGLContextSetCurrentAutoRestore(UnityDisplaySurfaceBase* surface)
  : old(surface->api == apiMetal ? nil : [EAGLContext currentContext]),
   cur(surface->api == apiMetal ? nil : ((UnityDisplaySurfaceGLES*)surface)->context)
{
   if (old != cur)
     [EAGLContext setCurrentContext:cur];
}

Afterwards you just need to go to Classes/UnityAppController+Rendering.mm and add

EAGLContextSetCurrentAutoRestore autorestore(GetMainDisplaySurface());

to

static void UnityRepaintImpl(bool forced)

so it looks like this

static void UnityRepaintImpl(bool forced)
{
   @autoreleasepool
   {
     EAGLContextSetCurrentAutoRestore autorestore(GetMainDisplaySurface());
 
     Profiler_FrameStart();
<...>

again, i cannot even build 4.x now, so you need to use c/objc knowledge to fix possible compilation errors (if i forgot to mention some incudes or smth)

 

参考自:http://forum.unity3d.com/threads/dictation-siri-keyboard-crash.358123/

 

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

分享:
开发与运维
使用钉钉扫一扫加入圈子
+ 订阅

集结各类场景实战经验,助你开发运维畅行无忧

其他文章
最新文章
相关文章