Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

XR Ray Interactor getting "trapped" inside the UI canvas

Discussion in 'AR/VR (XR) Discussion' started by blackfox_studio, May 24, 2020.

  1. blackfox_studio

    blackfox_studio

    Joined:
    Apr 8, 2019
    Posts:
    40
    I have followed the tutorial


    Overall, the ray interaction seems working but with one strange behaviour. For the records, I'm displaying a simple Canvas with one button on it.
    When I use the XR Ray Interactor component on the right controller and I point at the canvas, I can select buttons and move the ray inside the canvas but then I cannot leave the limit of the canvas anymore. They ray looks like "trapped" inside the canvas. Sometimes the ray gets detached by the canvas but when I point it around at some point it snaps to the canvas again.

    The problem happens as soon as I activate the checkbox "Enable Interaction with UI GameObject" in the XR Ray interactor

    If you check the screenshot, you will notice the hand is pointing outside the canvas but the ray snaps towards it.

    What could be the problem?
     

    Attached Files:

    Last edited: May 24, 2020
  2. XLRLimits

    XLRLimits

    Joined:
    Feb 13, 2016
    Posts:
    2
    Hello, i have the same issue
     
  3. blackfox_studio

    blackfox_studio

    Joined:
    Apr 8, 2019
    Posts:
    40
    It's probably a bug, I suggest to open a support ticket linking this page. I have done the same, maybe they will notice it
     
  4. XLRLimits

    XLRLimits

    Joined:
    Feb 13, 2016
    Posts:
    2
  5. blackfox_studio

    blackfox_studio

    Joined:
    Apr 8, 2019
    Posts:
    40
    Thanks a lot, I will give it a try and let you know :) Out of curiosity, was our configuration very different from the right one?
     
  6. blackfox_studio

    blackfox_studio

    Joined:
    Apr 8, 2019
    Posts:
    40
    Ok that project work even with 0.9.4 but when I try to reproduce the exact same configuration on my project it doesn't work. The only difference I found was this "Target Display" option which doesn't appear in my Camera configuration.

    Not sure why Unity is ignoring this post.


    Screenshot 2020-05-31 at 17.49.15.png Screenshot 2020-05-31 at 17.44.43.png
     
  7. blackfox_studio

    blackfox_studio

    Joined:
    Apr 8, 2019
    Posts:
    40
    Ok found the problem: it's the Camera component.
    You just need to copy the camera component inside the XRRig from the UICanvas demo scene into your project and it will work. No need to downgrade to 0.9.3.

    I hope Unity will publish a fix in the next release

    Thanks a lot, without your help it would have been impossible to catch it!! :)
     
  8. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,662
    If you create your camera properly, this problem never happens. That's probably why it's being ignored - are all of you following that tutorial? I've never seen this problem myself, on many projects.

    There could be a bug in the tutorial. Most youtube tutorials I've seen are unreliable: they don't get updated when the API changes or when Unity releases patches ... so they tend to get broken quickly, and I generally ignore them.
     
  9. azganmtgo

    azganmtgo

    Joined:
    May 3, 2020
    Posts:
    11
    Hey there bois. Had the same problem adding the "MainCamera" tag to the doing the world space thingy fixes the issue. Shoutout to my boys at Unity for whatever they did to make it happen.

    Also a43 your post is so insubstantial, nobody cares that you never have this problem please remove it.
     
    wm-VR and kirbycano98 like this.
  10. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,662
    You shouldn't have a project without a MainCamera tag. Unity creates it for you every time you make a new Scene (and you can't disable this without a lot of effort) which suggests that you - at some point - deleted it. That's a bad idea, since Unity has pretty much always required it (at least since 2012).
     
  11. wm-VR

    wm-VR

    Joined:
    Aug 17, 2014
    Posts:
    122
    Yes it fixed the weird "snapping" problem but now I can't click on the button anymore. It's just hovering and selecting but the OnClick event isn't get fired. Changing back the Camera tag to "Untagged" makes me fire the OnClick event but in exchange for this snapping problem with the ray.

    Is there a solution for this yet?
     
  12. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,662
    What's the problem? So far this thread appears to have been:

    1. Follow a broken tutorial
    2. That creates an invalid Unity scene
    3. ... which doesn't work
    4. But everyone that does NOT follow this tutorial, and writes normal Unity scenes, following the official Unity docs ... it works 100% of the time.

    There's some problems where if you try to convert an existing scene to XR/VR then some of the auto-convert code from Unity is incorrect and will break bits of your scene (for instance: it thinks that all RenderTexture cameras are actually VR cameras, which is really stupid, and impossible). For those cases you can either read the docs and look at your Camera objects and manually set the values to what they should be for your game -- or you can delete your camera + rig and use the one-click "Add Rig" feature in XRToolkit that will create a fully correct camera + VR settings for you.
     
  13. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    I ran into this as well and it was a main camera issues. WHY didn't I have a main camera ? Because when your working on multiple platforms it becomes meaningless. I have different cameras for each XR rig, for flat, different cameras for switch vs xbox vs ps. All with different components/configurations.

    My last project was a cockpit game and that was even worse with 6 cameras for each platform all rendering different parts of the scene.

    It wasn't apparent that it had to be setup as "main camera". Really it should be assignable in the component, that would have made it clear and be more scale able.
     
    a436t4ataf likes this.
  14. BrBarry

    BrBarry

    Joined:
    Jul 16, 2019
    Posts:
    10
    I had a similar problem, what found I was missing from my UI canvas was another (new) tracking script that is in the UI demo mentioned by @XLRLimits. 'Tacked Device Graphic Raycaster'. No need to downgrade, works with the current XRI Toolkit preview package 2.0.0-pre.6
     
    a436t4ataf likes this.
  15. BrBarry

    BrBarry

    Joined:
    Jul 16, 2019
    Posts:
    10
  16. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,662
    Please don't.
     
    hippocoder and KirillKuzyk like this.
  17. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,722
    I've thrown it out of the airlock so I doubt it will return.
     
    a436t4ataf likes this.
  18. StudioZ7

    StudioZ7

    Joined:
    Nov 13, 2021
    Posts:
    9
    I spent the day trying all these approaches - and others - but, in the end of the day, it was totally my mistake:
    I was using a canvas with a button which had lots of scripts attached, but one of them was duplicated (the same script was attached twice and two different actions were performed using the same script. Everything on the same button).
     
  19. JoelWall

    JoelWall

    Joined:
    Nov 11, 2020
    Posts:
    2
    None of the above solutions worked. For some reason when i add the main camera tag to my VR Rig camera, the screen is black in game.
     
unityunity