Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[30USD] SteamVR UI Input System

Discussion in 'Assets and Asset Store' started by arklay_corp, May 26, 2016.

  1. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242

    SteamVR - UI Input Module v1.0
    Link to the store: SteamVR - UI Input Module
    Easy integration of the SteamVR controllers with Unity's uGUI system.

    It also can be used as a base to extend unity's input system (Input and GraphicRaycaster modules)

    It includes a custom Input Module and a custom Graphic Raycaster allowing to use steam vr controllers to interact with the Unity native UI system.

    Instructions:
    1. In the EventSystem gameobject remove (or deactivate) Unity's Input Module (usually Standalone Input Module)
    2. Add our SteamVR Input Module
    3. Add at least one Steam VR Pointer and configure which physical controller should follow
    4. (Optional) Add a line renderer prefab to use it as a laser beam
    5. (Optional) Add a object to use as a hit indicator
    6. In your canvas (or canvases) remove (or deactivate) Unity's Graphic Raycaster
    7. Add our SteamVR Graphic Raycaster

    All native controls work, including Scroll View and the controller virtual Scroll wheel

    Full source code is included, as well as an example scene showing every native control. I use this asset for my own projects, so I will keep improving and expanding it.

    If you have any comments, doubts, feature request or find some control misbehaving just let me know
     
    Last edited: Jun 8, 2016
  2. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    Finally the package is accepted and live in the store!
     
  3. blueteak

    blueteak

    Joined:
    Feb 19, 2013
    Posts:
    139
    How can I change the angle/position at which the ray comes out? I'd like to make it so that it comes out of where the hand would be (like a pointing motion) instead of the top (like a thumbs up).
     
  4. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    For the drawing of the ray you should modify SteamVRPointer, the region named "Laser and Hit", and you will also need to adjust the RaycastAll method in the same class, most likely change the "worldNormal = m_trackedObjectTransform.forward" to your needs
     
  5. blueteak

    blueteak

    Joined:
    Feb 19, 2013
    Posts:
    139
    Created a new variable PointerObject which is just a gameObject nested inside the controller that it uses to define m_TrackedObjectTransform. Works like a charm!

    Thanks for pointing me in the right direction, your UI system is fantastic :D
     
    Last edited: Aug 10, 2016
  6. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    That's a very good and elegant solution!

    I'm glad you like it :p
     
  7. taiku

    taiku

    Joined:
    Aug 26, 2013
    Posts:
    8
    Hey I bought your asset! A few questions:
    1. How do I also support mouse and keyboard?
    2. I wanted to recommend a better folder structure similar to most of Unity's packages (seperate scripts, materials, prefabs, scenes etc). Can explain more if you don't know what the structure is.
    3. Is it possible to use this for Gaze only (instead of SteamVR controller)?
    4. Is there a repo I can be added to so I can contribute?
    Thanks!
     
  8. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    Hi Taiku, thanks for buying it. Your answers:

    1.- Not by itself, you will have to add the proper input module and activate one or the other.
    2.- I know that structure, but I dont like it, I can see in the project view what is a script, what is a material etc... I dont need to have them in different folders to organize them. Instead I prefer to separate in folder by concept, and avoid ending up with a huge script folder containing scripts that doesnt have to do anything with each other.
    3.- Again, it is possible, but you will have to create a new input module (you can take the one included as a starting point)
    4.- Sorry, I can't give you access to my private repo. But if you think something is worth to contribute you can post it here and I can add it to the asset if it's useful to the community (also I dont want to take credit from your work)

    * More about the folder structure. If you are developing a war game (lets say a better version of CoD inifinite crap) a tutorial will suggest something like this for the guns:

    Code (CSharp):
    1. + ...
    2.    + Guns
    3.          + Scripts
    4.           |      + Knife.cs
    5.           |      + Gun.cs
    6.           |      + Rocket.cs
    7.          + Materials
    8.           |      + Knife.mat
    9.           |      + Gun.mat
    10.           |      + Rocket.mat
    11.          + Prefabs
    12.                  + Knife.prefab
    13.                  + Gun.prefab
    14.                  + Rocket.prefab
    Now as the project grows, each time you want to add a new weapon you need to add new files in 3 different folders (probably more). I prefer to have separate folders per concept, so each new concept will be self contained in its folder:

    Code (CSharp):
    1. + ...
    2.    + Guns
    3.          + Kinfe
    4.           |      + Knife.cs
    5.           |      + Knife.mat
    6.           |      + Knife.prefab
    7.          + Gun
    8.           |      + Gun.cs
    9.           |      + Gun.mat
    10.           |      + Gun.prefab
    11.          + Rocket
    12.                  + Rocket.cs
    13.                  + Rocket.mat
    14.                  + Rocket.prefab
    This structure also makes more sense if you want to use asset bundles (which you probably want)
     
  9. taiku

    taiku

    Joined:
    Aug 26, 2013
    Posts:
    8
    Hmm I thought it added SteamVR input - not replaced mouse and keyboard. For my needs its not as useful without that.

    I can see why you might like that way but it comes down to preferring composition over inheritance. Everything should be as independent and generic as possible. Prefabs are the composition that bring them together. You *shouldn't* really able to separate cleanly into a hierarchy.

    For example:

    Code (CSharp):
    1. + Models
    2.         Hilt
    3.         Barrel
    4.         Scope
    5. + Scripts
    6.          ProjectileSpawner
    7.          Reloadable
    8.          DamageDealing
    9. + Prefabs
    10.          Rocket (DamageDealing) {Hilt, Barrel}
    11.          Gun (Reloadable, ProjectileSpawner-> Rocket) {Scope, Barrell}
    12.          Knife (DamageDealing) {Hilt}
    If it was a reusable asset (or for one) I would still follow this structure but would simply start at a higher level so I could export, maybe Weapons -> Materials, Prefabs, Etc.

    Even if I was to follow your example inside each of those folders I would still split by type - into Script/Material/Prefab because it could get easily cluttered and in general I'm looking for *something* for gun - example I want guns prefab not a list of all dependencies of gun. And as you add more scripts or different materials or sounds the list grows and grows.

    Even granted the composition above, I wouldn't want one super massive Materials/Models folder, so I would still split at the highest level possible.

    For this asset it was hard to identify where the prefabs were at first, I thought they weren't included - folders by type would have helped - or even the organization you showed above.

    Everything is just dumped into a UI folder. I fail to see any organization.
     

    Attached Files:

    • ddd.PNG
      ddd.PNG
      File size:
      8 KB
      Views:
      1,074
    Last edited: Nov 11, 2016
  10. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    SteamVR input replaces standalone input because it doesn't make sense to have both active at the same time (moving the camera with the HMD and the mouse at the same time can be very dizzy) but it uses composition, you can have both at the same time and activate one or another.

    About the folder structure, I didn't say that one structure is better than another I just explain why I prefer that and which one in my experience works better.

    You can add more folder depth to separate scripts, prefabs etc... but when there aren't many files (like in this case) I prefer something cleaner and just be able to see everything at the same time.

    In unity, and software development in general, there isn't just one right and one wrong is just about decision and being able to take and explain that decisions.

    It all comes down to: does the asset work for you? do you need some help to integrate it into your idea? Moving files around if you prefer some other organisation shouldn't be a problem
     
  11. taiku

    taiku

    Joined:
    Aug 26, 2013
    Posts:
    8
    I agree that there is not a right way, I was explaining why most prefer the other - and it just seemed like this asset didn't have any structure at all, so I just wanted to recommend a structure most of the asset community uses, the unity tutorials teach and is generally accepted as best practices. But I understand why you want to keep your own for your own preferences.

    It can make sense if you have a PC camera and a SteamVR camera and would like a shared UI they can both access. Kind of like fantastic contraption has a menu on the PC - but I also want the SteamVR player to be able to access it. It might be a niche use - but its what I was looking at.
     
  12. Mister_Horrible

    Mister_Horrible

    Joined:
    Apr 12, 2015
    Posts:
    6
    @arklay_corp Great asset! Thank you for this. I am having a couple small issues that I would appreciate some help with though. For some reason, whenever pressing a button on a canvas there is some weird flickering of the UI happening. This doesn't show up in the editor game view, only in the headset. All the buttons and other UI elements work the UI just flickers whenever a button control is clicked on. Also I can't seem to get the hit indicator to show up and the line renderer renders through the canvas. Again, the UI elements work fine, but I feel like the intended behavior isn't happening. Thanks again for the module, please help if you can.
     
  13. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    Hi @GeoJohn, thanks for your compliments, they mean a lot :)

    Can you share which unity version are you using? as you can see the code doesn't have anything to do with the rendering so the flicking you are seeing must be related with something else... are you using custom shaders? or maybe your UI components share the same z coordinate?
     
  14. Mister_Horrible

    Mister_Horrible

    Joined:
    Apr 12, 2015
    Posts:
    6
    @arklay_corp I'm using 5.4.3f1

    I am using the Lab Renderer in this project, so I'm beginning to wonder if that has something to do with the flickering. Any idea why the hit indicator never shows up and the "laser" pointer goes through the canvas? The buttons and all other UI objects work, but I just thought that I would be seeing the sphere object show up where the laser hits the canvas. I have populated the Steam VR Pointer script attached to my Event System with the hit prefab, but never see it.
     
  15. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    It's very weird, it's just a simple raycast, if the system works properly (the right UI element gets hit) the sphere should appear in that element.
    Where does the sphere actually appear? too far, too close, it doesnt shot at all?
     
  16. Mister_Horrible

    Mister_Horrible

    Joined:
    Apr 12, 2015
    Posts:
    6
    The sphere doesn't show up at all and the the line renders through the canvas, but the buttons still work.
     
  17. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    Could you send me somehow your project (or an example) for me to reproduce the problem and help you out?
     
  18. Mister_Horrible

    Mister_Horrible

    Joined:
    Apr 12, 2015
    Posts:
    6
    The issue turned out to be a scaling problem. My SteamVR play area was scaled up very large for the specific project I was working in. Once I scaled down the camera rig/play area to (1,1,1) and resized the canvas everything worked perfectly. Thank you for all your help and the wonderful module!
     
  19. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    Great, GeoJohn! I'm glad you solved it.

    And thanks for your compliments
     
  20. atomtwist

    atomtwist

    Joined:
    Mar 20, 2013
    Posts:
    32
    Hey. I just bought the Asset. Works great :D
    I got a question though:
    The way it works right now, when dragging a slider, but loosing focus of the handle with the pointer, the drag stops & the slider gets deselected.
    Can I change it somewhere, so that while the trigger is pressed & dragging it doesn't loose focus?
     
  21. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    Hi atmotwist,
    Sorry for not answering for a week!
    What you want to achieve should be easy to implement, the input module is just a finite state machine, you should look there and modify the event (when pointer goes out of the UI element) that makes the state machine transition and makes it lose the focus
     
  22. Andrzej-Skibinski

    Andrzej-Skibinski

    Joined:
    Apr 16, 2014
    Posts:
    13
    Hello. We have bought this asset for out Vive testing, and so far it works nicely. But I also have the problem with sliders. I think it would be great if you would implement kind of "snap" to sliders. When you point at slider and start dragging it, it should keep dragging the handle even if pointer is out of slider area. Only when you release trigger, it will get back to normal working order. This would make for much easier controls over any sliders, as it's pretty hard to track the sliders handle, unless it's very big

    Thanks in advance.
    Best Regards
    Andrzej Skibiński
    Sito Poland
     
  23. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    I think you are right, I'm pretty busy at the moment finishing the ios implementation for my vlc asset, but I my next task will be to modify that.

    BTW, greetings from Kutno :)
     
  24. atomtwist

    atomtwist

    Joined:
    Mar 20, 2013
    Posts:
    32
    That sound great :) Thanks also for the reply.
    Btw it would be awesome if there was an alternative mode where you actually need to touch the UI controls with the controller, like they do it in Oculus Quill.
    In some cases a pointer is quite unprecise.

    Cheers
     
  25. jococo

    jococo

    Joined:
    Dec 15, 2012
    Posts:
    232
    Using Unity 5.4.0f3.Most recent version of SteamVR (updated today deleting previous steamVR before import).

    A few errors upon importing:

    Assets/U3D/SteamVR/UI/SteamVRPointer.cs(132,155): error CS1502: The best overloaded method match for `U3D.SteamVR.UI.Watchers.SelectDeselect.SelectDeselect(System.Func<UnityEngine.GameObject>, Action<UnityEngine.GameObject>)' has some invalid arguments

    Assets/U3D/SteamVR/UI/SteamVRPointer.cs(132,155): error CS1503: Argument `#2' cannot convert `method group' expression to type `Action<UnityEngine.GameObject>'

    Suggestions?
     
    Last edited: Jan 24, 2017
  26. QuantumCube

    QuantumCube

    Joined:
    Sep 28, 2014
    Posts:
    2
    I'm having an intermittent problem where the UI elements stop interacting and the laser doesn't show anymore. I've not yet been able to get it to be repeatable so I'm not exactly sure what is causing it. Just thought I would post this in hopes someone might have some insight or a solution. If I get more on this Ill post it.
     
  27. atomtwist

    atomtwist

    Joined:
    Mar 20, 2013
    Posts:
    32
    Happens when the app window, or unity game window is not focused. Click the window, and it'll reappear.
    Is pretty stupid though, as eg in our case prevents people from using the computer, while somebody else is painting in VR.

    Not sure if this could be improved, or if it's due to uniy's event system being silly
     
    QuantumCube likes this.
  28. QuantumCube

    QuantumCube

    Joined:
    Sep 28, 2014
    Posts:
    2
    Thank you Atomtwist!!!! This was driving me nuts. I've got an app that will be at a show on Tuesday. This will help immensely!!
     
  29. atomtwist

    atomtwist

    Joined:
    Mar 20, 2013
    Posts:
    32
    No prob.
    It's an easy fix, once you know it.
    But a lot of our beta testers, also get confused about that.
    Good luck with your show !
     
  30. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
  31. wesloc

    wesloc

    Joined:
    Feb 4, 2017
    Posts:
    14
    Hello everyone:

    I am new to all these unity stuff.

    I created following script and add to my button.

    When pointing the pointer to the button, ButtonHandler::OnPointerEnter() is called.

    However, to my surprise, the pointerEnter is null. I traced the code to EnterExit:process().
    The pointerEnter is set after the event is delivered.

    Does this mean that there is no way to check on which gameObject the PointerEnter is called?

    When OnPointerExit is called, PointerEnter is set to my button.

    Thanks in advance.


    class ButtonHandler : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
    {
    public void OnPointerEnter(PointerEventData eventData)
    {
    if (eventData.pointerEnter != null)
    {
    Debug.Log("OnPointerEnter:" + eventData.pointerEnter.name);
    }
    else
    {
    Debug.Log("OnPointerEnter: pointerEnter is null");
    }

    }

    public void OnPointerExit(PointerEventData eventData)
    {
    Debug.Log("OnPointerExit:" + eventData.pointerEnter.name);
    }
    }
     
  32. wesloc

    wesloc

    Joined:
    Feb 4, 2017
    Posts:
    14
    One more question regarding to the EventSystemTest scene.

    When I run the scene in unity, I do not see the controller even it is powered off. If I press the power button once, it brings up the steamvr UI.

    What did I miss?
     
  33. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    You can now which gameobject by checking where the script is attached (same as with the normal input system):
    Code (CSharp):
    1.  
    2. class ButtonHandler : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
    3. {
    4.    public void OnPointerEnter(PointerEventData eventData)
    5.    {
    6.       Debug.Log("OnPointerEnter:" + this.gameobject.name);
    7.    }
    8.  
    9.    public void OnPointerExit(PointerEventData eventData)
    10.    {
    11.       Debug.Log("OnPointerExit:" + this.gameobject.name);
    12.    }
    13. }
     
  34. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    Obviously if the controller is powered off you wont see it.
     
  35. Fanazador

    Fanazador

    Joined:
    Jul 3, 2017
    Posts:
    2
    @arklay_corp
    I just bought the asset and it helps a lot, though I have a problem where it stops working if I move the canvas at runtime.
    I tried to debugging it but couldn't find the problem.
    Thanks for the help
     
  36. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    Hi,

    Try updating the steamvr libraries to the latest update
     
  37. Fanazador

    Fanazador

    Joined:
    Jul 3, 2017
    Posts:
    2
    I found out that I just need to click on game screen after I moved the canvas, I must be tired yesterday.
    Thanks for the great asset.
     
  38. PostmodernJ

    PostmodernJ

    Joined:
    Dec 5, 2016
    Posts:
    3
    Im getting a strange problem when i include the sphere Blue on the laser pointer as hit prefab on the event system object. Everything seems to work ok, except I'm getting another large ghost blue sphere flashing at 0,0,0 world ordinates, as the laser crosses ui elements on the menu behind.. It is worst if the ui element hovered over is a toggle with a ui text component on top , then the ghost sphere is permanently in view.
     
  39. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    i cannot reproduce your problem, can you send me on private message an example project?
     
  40. Adrian_LM

    Adrian_LM

    Joined:
    Aug 1, 2017
    Posts:
    5
    Hi,

    Can this asset work together with native unity input system?
    I require both VR and normal unity input for my project.

    Thank you!
     
  41. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    You could add both, and 90% of the time it should work, but there could be collisions... ideally you should enable/disable acordingly to avoid unexpected behaviour and race conditions
     
  42. marpione

    marpione

    Joined:
    Apr 16, 2016
    Posts:
    26
    Hi, will this work with latest unity versions such as 2017.2f. or should I wait for an update?
     
  43. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    it should work on 2017.2
     
  44. thenonamezz

    thenonamezz

    Joined:
    Dec 30, 2017
    Posts:
    1
    Will you update this so it works on the SteamVR plugin 2.0?
     
  45. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    Hi,

    No, I dont even own a SteamVR anymore, but shouldn't be hard (the part regarding the Steam plugin is pretty localized, the hard part is the input system modificatoins)
     
  46. Ifi

    Ifi

    Joined:
    Jun 4, 2013
    Posts:
    3
    Please update for new SteamVR plugin asap. SteamVR_Controller & and Controller Manager don't exist.
    Thanks
     
    adrienverhulst and CloudyVR like this.
  47. jgwinner

    jgwinner

    Joined:
    Dec 21, 2016
    Posts:
    19
    Hey, your website is down, is this product supported anymore?
     
  48. Somneuro

    Somneuro

    Joined:
    Jun 6, 2019
    Posts:
    2
    Hi, you should really consider updating this module for the new SteamVR plugin or take the product down. This is completely unusable at the moment as I keep getting CS0246 errors, as well as Recursive Serialization errors. I would love to use this module (that I paid $30 for) because it is still very useful for steamVR, but at the current version this does not work at all!