Hello. I have been using xaml WebBrowser in my game for windows phone 8, And now on WP8.1 i use WebView. And when i come back from this WebView, using native back button, in the game, button also been pressed. In WP8 i used this code to control back button press
private void PhoneApplicationPage_BackKeyPress(object sender, CancelEventArgs e)
{
if(MiniBrowser.Visibility == Visibility.Collapsed) e.Cancel = UnityApp.BackButtonPressed();
else {
e.Cancel = true;
if(MiniBrowser.CanGoBack) MiniBrowser.GoBack();
else {
MiniBrowserClose(false);
}
}
}
How can i prevent back button press in game when WebView is showed in WP8.1?
P.S. I Didn’t find how to edit code in this post…
In my Project, i handle the BackButtonPress only in Mono’Code. In that function, when MiniBrowser.Visibility == Visibility.Collapsed, call a function in WP’Code to make it hide.
I need prevent a back button press in game, when i return to game from WebView it process a back button and exit from current menu
Just handle BACKPRESS in game not in WP‘code
I tried, but not succeed
public static bool BackButtonPressed() {
#if UNITY_METRO
if(isVisible!=null && isVisible()) {
if(Input.GetKeyUp(KeyCode.Escape)){
if(Back!=null)Back();
}
return false;
}else{
return Input.GetKeyUp(KeyCode.Escape);
}
#else.....
isVisible true if my WebView is Visible, Back is an Action,which closes WebView. But after i change visibility of my MiniBrowserGrid to false and come back into game, sometimes there is Input.GetKeyUp(KeyCode.Escape) event returns true. It Looks like, in this frame,when unity get’s focus, it processing Input.GetKeyUp which was pressed when some Grid in SwapChainPanel was visible.
What more can i try?If somebody can make it work please give me an example.