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.

How can i move a UI Canvas in VR like in bigscreen?

Discussion in 'AR/VR (XR) Discussion' started by V-J, Jun 4, 2019.

  1. V-J

    V-J

    Joined:
    Apr 1, 2015
    Posts:
    73
    Hi there, Can somebody point me in the right direction how to create a movable ui like bigscreen.
    I use the oculus intergration package.

    Greetz
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    I've never tried BigScreen, but Canvases are just 3D objects like everything else in Unity. Move it by changing its transform.position.
     
  3. V-J

    V-J

    Joined:
    Apr 1, 2015
    Posts:
    73
    Thx @JoeStrout for your reply!
    I use the UIHelper prefab in the oculus intergration package to have a laser pointer. With this i can interact with buttons and sliders. But how can i move and rotate / drag by clicking the trigger and put the canvas to a new location with the laserpointer tip until trigger is realeased? i have no idea how to achieve this in code, hope you can help me this.
     
    Last edited: Jun 5, 2019
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    Ah, you just have to detect when the trigger button is down (probably using the Input class, though you could also use an EventTrigger on whatever part of the canvas you want to be grabbable), and then while that is true, move the Canvas in the same way as the pointer.

    There are lots of ways to do that — easiest might be to actually use Transform.SetParent to put the Canvas transform under the controller object (i.e. the thing that represents the actual thing in your hand) while the button is down. Then set its parent back to nil when the trigger is released.
     
    V-J likes this.
  5. Jackalex361

    Jackalex361

    Joined:
    Nov 16, 2022
    Posts:
    1
    Please watch this video