Volume Camera Window Events

I am trying to hook into the Volume Camera Window events, namely OnWindowOpened OnWindowClosed and OnWindowFocus but I seem to be having trouble getting consistent results.

I use the AddListener method for each of these events from a predefined Volume Camera reference. I seem to get an OnWindowOpened callback when the game first starts, as well as an associated OnWindowFocus, but whether I close the game/reopen it thereafter I don’t seem to get any further events.

I am mainly using these to account for OnApplicationFocus and OnApplicationPause events not firing in line with opening/closing volumes.

The Volume Camera does sit in a different scene to my main content, and I have been using the Ignored Scenes functionality from PolySpatial Internal. Are these likely culprits for this functionality not working as expected, or are there other known issues with these events?

I seem to get an OnWindowOpened callback when the game first starts, as well as an associated OnWindowFocus, but whether I close the game/reopen it thereafter I don’t seem to get any further events.

We need to do some further handling of focus events – they’re not hooked up to the window being put in the background (aka closed by the user). The concept of “focus” is a bit odd on this platform, and we’re still working through exactly what that means (same with the OnApplicationFocus callback). But I’ve got a bug filed sort this out and fire these events more accurately. We’ll also document when you should expect to receive each notification in unity (including the app events).

I have been using the Ignored Scenes functionality from PolySpatial Internal

Don’t do that :slight_smile: All the bits behind that internal define are either unfinished or for internal testing – and the majority of them require functionality that is not compiled in to public release packages. What you’re seeing is just the front end UI. Some things may work for now (such as the ignored scenes bit), but it’s not guaranteed in any way. (it’s not the cause of the problem in this case, though.)

Thanks @v_vuk!

Okay, so it’s at least good to know that the inconsistency is to be expected at the moment.

If it’s of any use, when I run the game connected to Xcode I get logs from PolySpatialWindowManager.on(windowDidEnterBackground) as well as PolySpatialSceneDelegate.sceneDidEnterBackground() consistently when I close the app via the X button from the OS.

I also get logs from PolySpatialSceneDelegate.sceneWillEnterForeground() and PolySpatialSceneDelegate.sceneDidBecomeActive() when I then select the app again from the home menu.

If there’s any way of attaching to those events, that would be perfect for my purposes!

Haha noted! I was mainly using this out of necessity before the “Ignore Layers” functionality was introduced, so I think I can safely not use this anymore

Is there any update on this?
Currently in our bounded-volume app none of the following code fires any events:

With the exception of volumeCamera.OnWindowFocused firing once on app-start, but never after. Neither in simulator nor on device. We’re working with Unity 2022.3.18, Xcode 15.2, PolySpatial 1.0.3 and have our VolumeCamera defined in the startup scene (and is DontDestroyOnLoad, so is maintained during the entire lifetime).

We’ve tried closing the app (with the ‘x’) and opening it again and pressing the crown and opening it again, placing other apps in front of it or waiting for our app to go into the special paused state (when you don’t look at it for 30-60 seconds), but none of the above events fire.

I know .18 isn’t the latest at the time of writing this, but also didn’t see anything related to this in the release notes from Unity 2022.3.19 and 2022.3.20.

1 Like

Any update on this? Or are there any alternative solutions for this?

We want to use OnWindowFocused for both bounded and unbounded modes, and the event not worked when close/reopen the app.

We are using unity 2022.3.22f1 and PolySpatial v1.0.3 release.

The more recent release of PolySpatial (1.1.6) has deprecated the events from 1.0.3 and replaced them with a single event that you can subscribe to that gets fired whenever the Window State changes. This event returns a struct that you can read to see what has changed.

The struct returns a WindowEvent which you can check, or in your case you can probably just read the isFocused value. More info is in the docs here

However, if some of the bugs in 1.1.6 mean you can’t upgrade, you can also do this on the Xcode side, but this will require you to hook things up via the NotificationCenter within the UnityPolySpatialAppDelegate Swift file and a Native to Managed Callback to communicate the events back to Unity