I am having incredibly hard time with WP8 and Unity. I have an app that starts with XAML menu, and from there you can navigate to the Unity game. Everything works fine, except few things:
Sometimes the app crashes right after locking the phone
Sometimes the app crashes when you go back to the XAML part of the app from the Unity part
It crashes with the following message, but doesn’t throw exception, or starts the debugger.
The program '[2800] TaskHost.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.
I’m using the following function that triggers when you click the “Back” button in the Unity app.
Can you give me a direction what to do, or even where is the problem?
Also, if you know a better way of switching between Unity and XAML pages, please let me know.
so your called method would contain something like the following:
private void UnityPause_PauseExit(object arg)
{
AppCallbacks.Instance.InvokeOnUIThread(new AppCallbackItem(() =>
{
if (NavigationService.CanGoBack)
{
// do stuff
}else
{
// do something else
}
}), false);
}
However, I do not believe you will be able to use navigation or session state manager to handle anything unity related, unless it is some data set you’ve been pumping between unity engine and the XAML frontend.
in my experiences so far, there is no way to dynamically change swapchainbackgroundpanels and maintain the current unity engine instance running… it dies along with hooked event handles etc… so, currently performing any XAML page navigation will fail. You need to change mind set to think “single page” with two layers… one for XAML stuff and DirectX in background frame buffer while using callbacks between.
The thing is, it SOMETIMES fail, not everytime. We were led into thinking that that was the right way, and we continued working on the app. When it came to beta testing, it started failing.
I’ll try the AppCalbacks stuff, and report if there is a success.
I tried with this approach, but failed. Tried making the UnityBridge static, thinking that would help, but I failed there too.
If anyone knows a solution, please post in this thread.