Any place in the game can be entered, as long as the call voice input, will inevitably cause the app crashes, the workaround is as follows:
OK, so essentially the gist of it was that Siri wants GL context and to be rendered alongside your view. So your 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's looks like that
struct unitydisplaysurfacebase; <...>classeaglcontextsetcurrentautorestore{public: Eaglcontext* Old ; Eaglcontext* cur; Eaglcontextsetcurrentautorestore (eaglcontext* cur); Eaglcontextsetcurrentautorestore (unitydisplaysurfacebase* surface); ~Eaglcontextsetcurrentautorestore ();};
Then in CLASSES/UNITY/EAGLCONTEXTHELPER.MM
Add
" 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){ if (old! = cur) [Eaglcontext setcurrentcontext:cur];}
Afterwards 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 are need to use C/OBJC knowledge to fix possible compilation errors (if I forgot to Mention some incudes or smth)
Reference from: http://forum.unity3d.com/threads/dictation-siri-keyboard-crash.358123/
iOS Voice input crashes