- Home /
know when GVR raycaster is looking at nothing
So I am building a vr video player for cardboard. I have made a pause menu that pops up when you pause it, but I want you to be able to look off the menu and click on the video and it go back to playing and hide the pause menu. I assume the best way to do that is to (when not looking at anything and button pressed hide menu) I tried OnGvrPointerHover but that only shows you when you are hovering over the specific object that has that code on it. I just want to be able to know when the player isn't looking at any item in my pause menu. hover = null kinda thing. I know there is something that is telling the reticle to enlarge or shrink, I want to know what makes it shrink! "when reticle is tiny and clicked do this".
Here in this doc it says the GVRREticuleObject has a function which is called when the user pulls the trigger. Idk how to use it but maybe if you did it would help you. Or maybe you can just put a gameobject in between the UI elements and the video screen and make it invisible to the renderer.
I thought about the invis UI element, but then the reticle would react as if it was over an object, and I didn't want that.
Answer by Sir-Gatlin · Jul 11, 2017 at 05:27 PM
What I ended up using was some code I found on a forum. to be honest not 100 sure how its working but I know its reading a raycast from the camera and will list everything it sees in the list, so I am checking if the list is empty, if so then I must be looking off the menu and if they tap the screen it will properly close the pause menu when you click off of the menu itself
PointerEventData pointer = new PointerEventData(EventSystem.current);
pointer.position = Input.mousePosition;
List<RaycastResult> raycastResults = new List<RaycastResult>();
EventSystem.current.RaycastAll(pointer, raycastResults);
if (raycastResults.Count == 0 && poppedUp == true)
{
hide();
player.Play();}