SteamVR Developer Hardware

SteamVR Developer Hardware

Getting the Prop_SerialNumber_String from Unity C#
Hi, I'm having a tough time getting this property. Has anyone successfully implemented a get method for this in Unity?

Is there perhaps an easier way to get a controller serial number than this property?

Edit: Got the property by making a getter that takes device id as an argument. Code below for anyone else stuck on this problem.

using UnityEngine; using Valve.VR; public class GetDeviceProperty : MonoBehaviour { public static string GetStringProperty(CVRSystem hmd, uint deviceId, ETrackedDeviceProperty prop) { var error = ETrackedPropertyError.TrackedProp_Success; var capactiy = hmd.GetStringTrackedDeviceProperty(deviceId, prop, null, 0, ref error); if (capactiy > 1) { var result = new System.Text.StringBuilder((int)capactiy); hmd.GetStringTrackedDeviceProperty(deviceId, prop, result, capactiy, ref error); return result.ToString(); } return (error != ETrackedPropertyError.TrackedProp_Success) ? error.ToString() : "<unknown>"; } }

I tried changing the serial number in the controller json, but it looks like that's not doing much. Unity still returns the original serial. Since we are creating a set of new tracked objects for sale, we need an identifier unique to the device type within the set. Anyone have an idea for this?
最近の変更はheteroerectusが行いました; 2016年12月4日 9時30分
< >
1-4 / 4 のコメントを表示
bendotcom  [開発者] 2016年12月4日 9時44分 
The serial number is set from a unique ID in the microcontroller. The S/N in the JSON is not used for anything.
Bummer... Is there any way to get the JSON serial number independently? I could think of a use for it :)
bendotcom  [開発者] 2016年12月4日 11時02分 
There is a field that lets you set left/right handedness in the JSON. Is that the kind of thing you're looking for?

You can also query the rendermodel string, but that's kind of a hack.
I originally was using the left/right handedness, but since we have custom tracked devices for hands, feet and more, all the lefts would end up interchangable.

This serial number solution worked great though, and I've got it working swimmingly. Thanks for your help!
< >
1-4 / 4 のコメントを表示
ページ毎: 1530 50

投稿日: 2016年12月4日 8時33分
投稿数: 4