Skip to main content
June 17, 2021
Solved

How to detect when guardian changes from Unity?

  • June 17, 2021
  • 2 replies
  • 2240 views

Hi,

 

I'm developing a roomscale game and I use OVRManager.boundary.GetGeometry(OVRBoundary.BoundaryType.OuterBoundary) to create a custom in-game visible boundary so that the player can align their playspace to the in-game playspace as they like. As part of this process they may decide to update their guardian, but then the geometry I previously fetched is out of date. One way to solve this would be to have an in-game way for the player to reset the in-game boundary and I would then just refetch the boundary. However, I'd prefer to automatically detect any change. I can't for the life of me find an efficient way to do this or any events.

 

My other thought is to just re-fetch and re-build the in-game boundary every couple of seconds but that also feels a bit lame 🙂

 

Help!

    This topic has been closed for replies.
    Best answer by

    To adjust the guardian the running application has to lose input focus. I think you could just verify the boundary every time the application gains input focus?

     

    public class FocusTest : MonoBehaviour {
        private void Awake() {
            OVRManager.InputFocusAcquired += OnInputFocusAcquired;
        }
    
        private void OnDestroy() {
            OVRManager.InputFocusAcquired -= OnInputFocusAcquired;
        }
    
        private void OnInputFocusAcquired() {
            Debug.Log("Verify boundary.");
        }
    
        private void OnApplicationFocus(bool hasFocus) {
            if (hasFocus) {
                Debug.Log("This might work too.");
            }
        }
    }

    2 replies

    Answer
    June 17, 2021

    To adjust the guardian the running application has to lose input focus. I think you could just verify the boundary every time the application gains input focus?

     

    public class FocusTest : MonoBehaviour {
        private void Awake() {
            OVRManager.InputFocusAcquired += OnInputFocusAcquired;
        }
    
        private void OnDestroy() {
            OVRManager.InputFocusAcquired -= OnInputFocusAcquired;
        }
    
        private void OnInputFocusAcquired() {
            Debug.Log("Verify boundary.");
        }
    
        private void OnApplicationFocus(bool hasFocus) {
            if (hasFocus) {
                Debug.Log("This might work too.");
            }
        }
    }
    June 17, 2021

    Thank you so much! I'm pretty new to all of this and that's a wonderful solution. You totally made my day, thanks!! 🙂