OnApplicationPause / OnApplicationFocus on Apple Vision Pro

How can we determine if our visionOS Unity application has lost focus?

Usually we use Unity’s provided functions like OnApplicationFocus and OnApplicationPause. But it does not seem like they function the way we would expect, as we don’t see them being triggered when a user opens the main menu on Apple Vision Pro, or when they resume our application.

Hi,

Is your app using PolySpatial? If it is, you can subscribe to an event in VolumeCamera called WindowStateChanged to get a callback whenever the volume camera window gets or loses focus.

If your app is not using PolySpatial (i.e. Metal) OnApplicationFocus and OnApplicationPause should work, as far as I know. Please submit a bug and a repro case if those are not working for you when in Metal app mode.

We are using Polyspatial, and targetting a MR environment with an exclusive unbounded environment. We don’t see the events being triggered.

We’ll implement your suggestion for the WindowStateChanged callback and test it out, thank you!

Is this documented anywhere that OnApplicationFocus and OnApplicationPause do not work with Polyspatial applications?

I’ve spoken with the engineer who is working on OnApplicationFocus in visionOS. OnApplicationFocus needs some bug fixes but will eventually work in PolySpatial and Metal - in PolySpatial it should trigger once all windows are closed.

In the meantime, I’ll make a task to add a public-facing note or docs to indicate that it currently does not work. Let us know if there’s any issues with getting WindowStateChanged to work!

1 Like

Sorry for the late reply your solution did work thank you for suggesting it!

Also appreciate that OnApplicationFocus may work in the future for PolySpatial.