fehaar / FFWD

This is the FFWD framework for XNA, that allows you to port Unity3D games to XNA for use on WP7 or XBox360 (XBLIG)
Microsoft Public License
133 stars 36 forks source link

Tracking Hardware Back Button... #64

Closed stanleyjoy closed 12 years ago

stanleyjoy commented 12 years ago

I want to track the Hardware back button in WP7 so that users can use that button to pause the game or move back in the main menu. The MenuUI is written in Unity C#, how do I go about and bring and different use to the back button other than quitting. Stan

mydiscogr commented 12 years ago

Hi

you can't directly in unity AFAIK but go into Game1.cs of FFWD template directory and Intercept back button there with this code

if (Microsoft.Xna.Framework.Input.GamePad.GetState(Microsoft.Xna.Framework.PlayerIndex.One).Buttons.Back == Microsoft.Xna.Framework.Input.ButtonState.Pressed) EventAggregatorService.service.sendMessage(this,UnifyInput.ON_BACK_BUTTON);

now EventAggregatorService.service.sendMessage(this,UnifyInput.ON_BACK_BUTTON); It's my event aggregator that send a message to unity and voila! back button works

I've a blog here www.bulldozer-mobile.com in next day I would post a series of article about my experience making a game in wp7 with unity :)

bye

fehaar commented 12 years ago

If you look in the Input class you will se a slight hack for the Phone that allows you to call the Input.GetButton*("Back") methods and get the result of the back button. It will only work on the phone.