When using Google Cardboard VR SDK for Unity, how can I detect when the Main Camera object looks at UI objects inside Canvas? OnPointerEnter() and OnPointerExit() happens when I look at 3D Objects in the samples project that Google offers, but there is no way to do it for UI Objects.
How to detect UI Objects from Main Camera object when using Google Cardboard VR SDK for Unity
507 Views Asked by Jay At
1
There are 1 best solutions below
Related Questions in UNITY-GAME-ENGINE
- How to use invokerepeating and make ui text fade in/out over time?
- Player input not working properly in unity
- Get block in Mesh Unity
- Does Unity render invisible material?
- Physics.OverlapSphere couldn't detect my ‘Player’
- Cannot sync non-player objects in Unity mirror
- How to script a simple collision using hands in OVRCameraRigInteraction?
- Drawing on 3D object at Unity
- How to Override Spline Rotation for Player-Controlled Car in Racing Game?
- Why doesn't my enemy shield take damage first. Instead both enemy and shield are being destroyed together
- unity + Vuforia balck screen in android AR app
- how do I change an objects tag when the game closes
- How to remove white space in a user's input through an input field in Unity?
- Timeline doesn't start eventhough it recognises the trigger input
- Ragdoll 2D Aiming
Related Questions in GOOGLE-VR
- anyone know how to pass 6Dof sensor data in Avtarposer?
- Google cardboard VR closing the whole application after pressing switching VR off button
- Building a 360-Degree Image Viewer with Interactive Rotation in Android
- VrVideoView is not importing after download google VR SDK. 360 3d video play on app
- Unity Build Failure: A failure occured while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
- Quickstart for Google Cardboard for Unity Plugin for Unity 2019.4.25f & later Doesn't Install The Samples Folder
- Changing from two lense into one view. Unity GoogleVR
- How to detect UI Objects from Main Camera object when using Google Cardboard VR SDK for Unity
- How to start in VR with google cardboard?
- How to assign event trigger pointer click as Fire1 in Google VR Cardboard Unity 2019
- Unable to check Cardboard XR Plugin in unity
- Cannot install HelloCardboard into unity
- Cardboard-xr-plugin causes the VR environment to stutter when moving the camera
- Unity | Use AR and VR in the same app but not simultaneously
- Unity GoogleVR DLLNotFoundException 'gvr'
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Based on your explanation, I guess you have set the
Render Modeof yourCanvastoScreen Space-OverlayorScreen Space-Camera. When you use one of these render modes, the position of your Canvas on the screen will never change, so you can never catch any element of the UI unless its bound includes the middle point of the screen. why? because you are usinggoogle VRand you have no joystick or something similar to control the cursor's position, therefore the cursor position is always (0, 0).Let's assume the cursor and Canvas, both, are children of your camera. You can move your camera by shaking your head, this way the canvas and the cursor move in comparison with other objects in your virtual world based on camera movement, but they never move in comparison with each other.
So what's the solution? I think you can set the
Render Modeof your canvas toWorld Space. This way your canvas will be an object in the world that the cursor can navigate through it. I know you think it's weird, cause likely you want to always see the canvas just in front of your eyes. So I think you just have one solution:Do not change the
Render Modeof the canvas, locate All UI elements on the canvas, it's better to locate them near the edges of the screen and also with adequate distances, then write a script to do this: When the cursor is moving, calculate the direction of movement and find out which UI elements could be the target of this movement, move it towards the middle point of the screen, when its bound includes the middle point, itsOnClickwill be called. After that, you must return all UI elements to their early positions. Also if the cursor stopped moving before the UI element reaches the middle point, you must return all UI elements to their early positions.I know, it's so hard to handle this, but it's the only way I could propose.