0

I want to pause a Unity game when the Xbox home button is pressed. Is there a way to detect it? There is no direct Unity key mapping for it. For PS4 I did this:

if (UnityEngine.PS4.Utility.isSystemUiOverlaid)
{
    SetGamePaused (true);
}

Is there a similar API for PC / Xbox?

mukul
  • 171
  • 1
  • 15
  • 1
    Last time it was discussed (approx. 2 years ago), it was not implemented: https://forum.unity.com/threads/windows-10-using-xbox-game-bar-features-from-unity-application.1194838/ . I suggest you post on the Unity forums and maybe a dev can give you a more accurate and recent answer. From what I searched so far, there doesn't seem to be any implementation for the X button binding or the XBOX/Windows Game overlay in Unity. – TheNomad Mar 27 '23 at 21:05
  • You are right. I tried OnApplicationFocus and OnApplicationPause but they respond to keyboard and mouse inputs and not controller input. – mukul Mar 28 '23 at 06:39
  • Minor note, there is a Game Bar SDK for Windows and XBox, but you'd need to implement it manually. Then again, there is no evidence it could be easily ported to Unity, so if a Unity Dev doesn't give you a better answer, you'll have to wait for Unity Technologies to implement it. – TheNomad Mar 28 '23 at 07:35

1 Answers1

0

As mentioned in the comment, last time it was discussed (approx. 2 years ago), it was not implemented. Your best bet is to post on the Unity forums and hope or pray a Unity dev can give you a more recent answer or at least a nudge in the right direction.

MS did recently release the Windows/Xbox Game bar SDK to third parties though, but you'd most likely need to implement or port it manually somehow. Then again, there is no evidence it could be easily ported to Unity, so maybe a Unity Dev or someone that did it on the Unity Forums can help you out.

Lastly, if you want OOTB support in the engine, you'll have to wait for Unity Technologies to implement it, but keep in mind you'd have to request it. The Unity Feedback platform was decommissioned some time ago and was replaced by the Unity Forums, or at least, Unity Technologies says it's temporary (to quote UT: "this will be the primary source of community feedback until we’re able to get a new, more scalable, and dedicated feedback solution in place").

Still, if you want to have a go, here is the page I am talking about: https://developer.microsoft.com/en-us/games/products/game-bar/ . The implementation seems to be C#-oriented, but developed for UWP. Not sure if you can pull off a Unity build for UWP and "force" the MS SDK integration.

Here are some resources:

  1. GitHub
  2. MS Learn
  3. Xbox One + UWP deployment for Unity <- this might help, although it's aimed at test projects and doesn't include publishing, but maybe you could use it for a proof-of-concept to see if it's worth it or doable.

Hope this helps or at least moves you in the right direction until a better solution appears. Good luck!

TheNomad
  • 892
  • 5
  • 6