Author Topic: Oculus Rift "Look At Button" Problem: Raycast to Button on flying Texture  (Read 3800 times)

CaptainCrunch80

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Hi,

I am trying to use the Oculus Rift with NGUI. It looks great and I think I can handle most situations already, because I followed this
guide that helped me a lot setting up NGUI to work in a VR environment http://www.beowulf99.com/blog/?p=1014

But one problem is remaining. I want to hover and then 3 seconds later click buttons just by looking at them.

Please take a look at the provided picture, this is just an example.

So what I do is raycasting from the center of the right camera  in look direction and try to hit the button. Of course I hit the textured plane  ... but not the button.

I would have given up already, but no matter in what angle I look at the plane with the NGUI gui texture, when I mouse over the button it is clickable and reacts to hover.

So I believe there is some kind of weird magic at work to click the button that is rendered to a texture and shown on that plane.

I looked at a lot of code in UICamera and so on, but I can not find what makes this work and re-engineer it for my look at button plan.

Do you have a clue?! Anybody?  :o
« Last Edit: February 20, 2014, 07:15:54 PM by CaptainCrunch80 »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Oculus Rift "Look At Button" Problem: Raycast to Button on flying Texture
« Reply #1 on: February 19, 2014, 12:34:52 PM »
What layer is your UI on, and what layer is your world on? What mask are you using for your Raycast?

I would simply add some custom input logic to your camera (UICamera.onCustomInput delegate).

CaptainCrunch80

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Oculus Rift "Look At Button" Problem: Raycast to Button on flying Texture
« Reply #2 on: February 20, 2014, 07:15:05 PM »
Thanks a lot ArenMook,

with your hint to UICamera.onCustomInput I managed to do this.

It involves
  • Raycasting from the right eye camera
  • if hit is a plane with a gui texture get hit texture coords
  • raycast into gui camera view with gui coords to camera pixel size
  • send OnHover, OnClick etc. to the hit gui object

Works like a charm, but it is very late and I need to go to bed. So I post my solution this weekend after cleaning up and making some further tests.

*****