SteamVR Developer Hardware

SteamVR Developer Hardware

aaron.leiby Jan 12, 2017 @ 8:39am
Unity SteamVR plugin v1.2.0
The SteamVR plugin for Unity has been updated on the Unity Asset Store.

http://u3d.as/content/valve-corporation/steam-vr-plugin

Please use this thread for reporting bugs.

Known issues:
  • The current beta version of Unity 5.6 breaks the normal operation of the SteamVR_UpdatePoses component (required for tracked controllers). To work around this in the meantime, you will need to manually add the SteamVR_UpdatePoses component to your main camera.

The biggest pain point for this update is the changes to SteamVR_Utils.Event if you were using that for your own custom events. See SteamVR_Events.cs for a template for adding your own custom events, and search the rest of the plugin for example usage. You can still directly Listen/Remove events, but I've also provided "Action" wrappers to cut down on runtime memory allocation if you are enable/disabling components often that listen for events.

Also included in this update is the InteractionSystem used by The Lab. See the included documentation for details. Note, this is only included in the version of the plugin downloaded using Unity 5.4 or newer.

The source for all three versions of the plugin are now hosted in a separate github repo here: https://github.com/ValveSoftware/steamvr_unity_plugin. This includes all the meta files, so you should be able to pull directly from there, which may make further updates easier. You can use this repo to submit change requests and report issues.

Finally, if you have problems downloading the latest version, sometimes you need to click on the little "inbox" icon in the upper left of the Asset Store window to go to the list of plugins you've previously downloaded, and update the plugin from there before importing it into your project(s).
Last edited by aaron.leiby; Jan 12, 2017 @ 8:40am
< >
Showing 16-30 of 64 comments
Agwulf Jan 12, 2017 @ 3:42pm 
I installed on Unity 5.5.0f3 and I'm getting these kind of errors:

Assets/Imports/HTC.UnityPlugin/ViveInputUtility/Scripts/ViveRole/ViveRole.cs(31,27): error CS0117: `SteamVR_Utils' does not contain a definition for `Event'

Assets/Imports/HTC.UnityPlugin/ViveInputUtility/Scripts/VivePose/VivePose.cs(49,27): error CS0117: `SteamVR_Utils' does not contain a definition for `Event'

It seems Vive Input Utility is not updated yet. Any fix for this in the meantime?
Last edited by Agwulf; Jan 12, 2017 @ 3:51pm
aaron.leiby  [developer] Jan 12, 2017 @ 3:50pm 
Originally posted by Arthur:
I installed on Unity 5.5.0f3 and I'm getting these errors:

Assets/Imports/HTC.UnityPlugin/ViveInputUtility/Scripts/ViveRole/ViveRole.cs(31,27): error CS0117: `SteamVR_Utils' does not contain a definition for `Event'

It seems Vive Input Utility is not updated yet. Any fix for this in the meantime?

For code like this:
SteamVR_Utils.Event.Listen("new_poses", OnNewPoses); SteamVR_Utils.Event.Remove("new_poses", OnNewPoses);
The new method is like this:
SteamVR_Events.NewPoses.Listen(OnNewPoses); SteamVR_Events.NewPoses.Remove(OnNewPoses);
Then you also need to update the callback (e.g. OnNewPoses in this case) to take the arguments that the old function was casting from the args variable.
E.g.:
private void OnNewPoses(params object[] args) { ... var poses = (Valve.VR.TrackedDevicePose_t[])args[0]; ... }
becomes simply:
private void OnNewPoses(Valve.VR.TrackedDevicePose_t[] poses) { ... }

You can also instead create an "Action" wrapper and enable disable that like so:
SteamVR_Events.Action newPosesAction; void Awake() { newPosesAction = SteamVR_Events.NewPosesAction(OnNewPoses); void OnEnable() { newPosesAction.enabled = true; } void OnDisable() { newPosesAction.enabled = false; }

For system events like "TrackedDeviceRoleChanged" see SteamVR_ControllerManager.cs as an example: https://github.com/ValveSoftware/steamvr_unity_plugin/blob/master/v5/Assets/SteamVR/Scripts/SteamVR_ControllerManager.cs

Finally, for completely custom events that you want to define yourself, you can take a look at the ChaperoneInfo.Initialized event/action as an example:
https://github.com/ValveSoftware/steamvr_unity_plugin/blob/master/v54/Assets/SteamVR/InteractionSystem/Teleport/Scripts/ChaperoneInfo.cs

The Teleport script also defines a few of its own:
https://github.com/ValveSoftware/steamvr_unity_plugin/blob/master/v54/Assets/SteamVR/InteractionSystem/Teleport/Scripts/Teleport.cs#L113

It also listens for the ChaperoneInfo.Initialized event.
Last edited by aaron.leiby; Jan 12, 2017 @ 3:53pm
Agwulf Jan 12, 2017 @ 3:53pm 
Ah thanks! Was also about to comment about TrackedDeviceRoleChanged, but it seems you read my mind.
aaron.leiby  [developer] Jan 12, 2017 @ 3:57pm 
Originally posted by Arthur:
Ah thanks! Was also about to comment about TrackedDeviceRoleChanged, but it seems you read my mind.
I think I will actually switch these to taking a EVREventType enum value instead of a string in the future.
Agwulf Jan 12, 2017 @ 4:05pm 
How about OnDeviceConnected? It has these two variables

var index = (uint)(int)args[0];
var connected = (bool)args[1];

casting the args. I'm guessing it would just be

OnDeviceConnected (uint index, bool connected)

maybe?
sharkdidit Jan 12, 2017 @ 5:24pm 
I can't find any events that correspond to KeyboardCharInput and KeyboardClosed in SteamVR_Events. How do we get Steam keyboard input now?
aaron.leiby  [developer] Jan 12, 2017 @ 5:27pm 
Originally posted by Arthur:
How about OnDeviceConnected? It has these two variables

var index = (uint)(int)args[0];
var connected = (bool)args[1];

casting the args. I'm guessing it would just be

OnDeviceConnected (uint index, bool connected)

maybe?
You want to copy what SteamVR_ControllerManager is doing. It uses "int index, bool connected" - which mirrors how it is being sent in SteamVR.cs: https://github.com/ValveSoftware/steamvr_unity_plugin/blob/master/v5/Assets/SteamVR/Scripts/SteamVR.cs#L238

The old code converted it immediately to a uint since it was being passed into GetTrackedDeviceClass which takes a uint instead of an int. In the new code, you can see we moved the cast to where we pass in the value instead.
Porkhe Pigatov Jan 12, 2017 @ 5:34pm 
Originally posted by aaron.leiby:
I cannot find any reference to "tracker_zeroed" in the SteamVR plugin code history going back to 4/15. Perhaps that was in a pre-release version of the plugin (it does seem vaguely familiar) or something you folks added locally? I explicitly removed SteamVR_Utils.Events in order to ensure I captured all existing uses of the old event system. This also requires devs to evaluate their own uses of that system, which I figure is a good thing since updating to the new system will reduce runtime memory allocations. You are obviously free to copy/paste the old event system back into your project though.

You're right, it seems to be a orphaned event, dating back to before the official plugin release. I searched our repo and the Valve stuff on Github going back a couple years. I thought I was losing my mind, but your reply reminded me that we'd had to modify the plugin a few times early on to work around some Rift DK2 issues. A few other devs made similar changes, if memory serves. I think a subsequent upgrade of the plugin stomped those changes, but we never noticed because we'd started using Vive devkits by that time.
Markwar Jan 12, 2017 @ 5:45pm 
Originally posted by aaron.leiby:
Originally posted by StancexChance:
After updating I got Ando's issue which I corrected but have an additional error that reads :

InitWWW is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'SteamVR_Update'.
See "Script Serialization" page in the Unity Manual for further details.
UnityEngine.WWW:.ctor(String)
SteamVR_Update:.cctor() (at Assets/SteamVR/Editor/SteamVR_Update.cs:27)

Any help on getting this fix would be greatly appreciated as I cant do anything atm.
I also cannot reproduce this in Unity 5.5.0f3. I just stepped through the code and it seems to be working as expected. It does call "new WWW" in its static constructor - I do not know why I don't get that error, however. I know web and mobile platforms often have additional restrictions, so maybe double check you are using Standalone/Windows? Do you have any other Player settings which might affect this?

I also saw this error once on 5.4.3xEditorVR-p3, though after reloading the editor without updating the SteamVR plugin and discarding any changes made, I haven't seen the error since. I'm guessing the error occurs because [InitializeOnLoad] means WWW is called before scene (and editor?) deserialization has completed and the main loop has been entered. It could all be timing. Unity is very unclear on which classes are safe to use outside of the main loop, and complains when you do. Arron, have you tried instantiating WWW inside of static void Update()? Why not if (wwwVersion == null) wwwVersion = new WWW(versionUrl)?
Radical Shnag Jan 12, 2017 @ 8:26pm 
Originally posted by Markwar:
Originally posted by aaron.leiby:
I also cannot reproduce this in Unity 5.5.0f3. I just stepped through the code and it seems to be working as expected. It does call "new WWW" in its static constructor - I do not know why I don't get that error, however. I know web and mobile platforms often have additional restrictions, so maybe double check you are using Standalone/Windows? Do you have any other Player settings which might affect this?

I also saw this error once on 5.4.3xEditorVR-p3, though after reloading the editor without updating the SteamVR plugin and discarding any changes made, I haven't seen the error since. I'm guessing the error occurs because [InitializeOnLoad] means WWW is called before scene (and editor?) deserialization has completed and the main loop has been entered. It could all be timing. Unity is very unclear on which classes are safe to use outside of the main loop, and complains when you do. Arron, have you tried instantiating WWW inside of static void Update()? Why not if (wwwVersion == null) wwwVersion = new WWW(versionUrl)?

I also encountered the "InitWWW is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead.", and restarting the Unity editor also stopped the occurrence of the error for me as well.

I am using Unity 5.4.0b19 (64-bit), and had upgraded by deleting then re-importing.
sasq64 Jan 13, 2017 @ 1:18am 
This new version removes both my controllers (they become disabled in Untiy when entering Play mode).
Downgraded to this patched 1.1 version
https://github.com/GaryniL/SteamVR-1.1.0-Patch
and got them back. Upgraded again but same thing.

jashan Jan 13, 2017 @ 3:22am 
Originally posted by aaron.leiby:
The biggest pain point for this update is the changes to SteamVR_Utils.Event if you were using that for your own custom events. See SteamVR_Events.cs for a template for adding your own custom events, and search the rest of the plugin for example usage. You can still directly Listen/Remove events, but I've also provided "Action" wrappers to cut down on runtime memory allocation if you are enable/disabling components often that listen for events.

While the migration is a bit painful - I love this change. I complained about the allocations the old approach was causing probably more than a year ago (that was even before I got my Vive ;-) ). So I can only say "at last!!!" ... also, the new way of doing this is actually much easier because you don't need to pass strings which could also have typos in them ... and "where was the documentation of what we can listen for again"? ;-)

I haven't actually tried if everything still works, yet ... just wanted to say: This change, I totally love. Thank you!
jashan Jan 13, 2017 @ 4:01am 
Originally posted by aaron.leiby:
I also cannot reproduce this in Unity 5.5.0f3. I just stepped through the code and it seems to be working as expected. It does call "new WWW" in its static constructor - I do not know why I don't get that error, however. I know web and mobile platforms often have additional restrictions, so maybe double check you are using Standalone/Windows? Do you have any other Player settings which might affect this?

I'm also getting this on Unity 5.4.3f3, this is for Windows 64 bit standalone builds, Scripting Backend Mono2x, Api Compatibility Level .NET 2.0. But the only thing that's weird is that you're not seeing this because I believe that's a fairly standard Unity error message when you call stuff from static initializers.

Here's a posting in Unity's blog explaining when and why they have added this: Serialization, Monobehaviour Constructors and Unity 5.4[blogs.unity3d.com]

Unfortunately, that blog posting is actually about another use case and the fixes they suggest won't help with what you're doing.

It took me a little while to find what you're looking for - but it's in the documentation: https://docs.unity3d.com/Manual/RunningEditorCodeOnLaunch.html

... which is what you're apparently already using. Except you have wwwVersion = new WWW(versionUrl); in the constructor instead of only registering the Update there. If you put those two together, the solution becomes kind of obvious.

I've changed this locally to:

static SteamVR_Update window; private static bool updateCheckInitialized = false; static SteamVR_Update() { wwwVersion = new WWW(versionUrl); EditorApplication.update += Update; } static void Update() { if (wwwVersion == null && !updateCheckInitialized) { wwwVersion = new WWW(versionUrl); updateCheckInitialized = true; } if (wwwVersion != null) { if (!wwwVersion.isDone) return;

Note sure if that's the most elegant way, but it should do.

Originally posted by StancexChance:
Any help on getting this fix would be greatly appreciated as I cant do anything atm.

Actually, it's just a runtime error generated by Unity. You can fairly safely ignore it - the only thing that probably breaks is the SteamVR Unity plugin update check.
Draconis Jan 13, 2017 @ 8:09am 
Getting a compiler error that won't even allow me to play in Unity.
Console:
Assets/SteamVR/InteractionSystem/Core/Scripts/Util.cs(538,5): error CS0119: Expression denotes a `variable', where a `method group' was expected
Seems to be a flub in their Util.cs code.

http://imgur.com/a/iJW7I

I just commented out the error line as a temporary fix to get back to work.
Last edited by Draconis; Jan 13, 2017 @ 8:15am
AK Jan 13, 2017 @ 11:37am 
Originally posted by draconis99:
Getting a compiler error that won't even allow me to play in Unity.
Console:
Assets/SteamVR/InteractionSystem/Core/Scripts/Util.cs(538,5): error CS0119: Expression denotes a `variable', where a `method group' was expected
Seems to be a flub in their Util.cs code.

http://imgur.com/a/iJW7I

I just commented out the error line as a temporary fix to get back to work.

Thank you for backing me up with this, I have received absolutely no response in this thread with the same problem. I posted on the first page and was promptly ignored, my bump didn't get a response either. Very annoying when I am completely stalled in my development.

I will attempt this temporary fix, but I would love some sort of response on any action that is being taken on this issue.

Commenting out a line of code does not seem like a very good long-term option to me.
< >
Showing 16-30 of 64 comments
Per page: 1530 50

Date Posted: Jan 12, 2017 @ 8:39am
Posts: 64