Author Topic: Need help on laser interaction with NGUI UIs  (Read 1882 times)

yifuqiao

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Need help on laser interaction with NGUI UIs
« on: January 17, 2017, 02:09:31 PM »
Hi, everyone.
I am working on a VR game, and I want to use NGUI.
The effect i am trying to achieve is described in this video:
https://www.youtube.com/watch?v=mD16LejMc9A

Basically, I want to interact with the NGUI UIs with the lasers shooting from my controller object.
The video shows it was done by implementing a custom input module.
However, I am not sure what is the proper way to achieve the samething with NGUI.
I read through the recent threads, and I think the only closest thing I have found is here:
http://www.tasharen.com/forum/index.php?topic=15063.0

It sounds like I need to implement a custom UICamera, and calling the delegates at the moment where I think the interaction should happen.

Could anyone confirm if I am on the right track.
VR gaming is popular nowadays, so I think this is probably done someone already.
I just want to make sure I am on the right track and not re-invent the wheels.

Thanks so much!

yifuqiao

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Need help on laser interaction with NGUI UIs
« Reply #1 on: January 17, 2017, 02:24:59 PM »
Maybe I could just re-implement the code below?
It feels to me this is what NGUI uses to do raycast.
All i need to change is cast the ray from my controller, and UI camera should handle everything afer that.
  1. static public Ray currentRay
  2.         {
  3.                 get
  4.                 {
  5.                         return (currentCamera != null && currentTouch != null) ?
  6.                                 currentCamera.ScreenPointToRay(currentTouch.pos) : new Ray();
  7.                 }
  8.         }
  9.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Need help on laser interaction with NGUI UIs
« Reply #2 on: January 18, 2017, 09:20:55 AM »
UICamera.onCustomInput can be set to whatever you want it to be. Furthermore you have full access to all input events in NGUI -- such as UICamera.GetInputTouch and UICamera.GetInputTouchCount, letting you create custom input event sources easily.