Created
November 6, 2017 16:02
-
-
Save hon454/57ba590a4f3f33d6172f9c1d7f60ad32 to your computer and use it in GitHub Desktop.
[SteamVR][Unity] Get tracked object name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using Valve.VR; | |
public class SteamVR_GetTrackedObjectName : MonoBehaviour | |
{ | |
private void Start() | |
{ | |
uint index = 0; | |
ETrackedPropertyError error = new ETrackedPropertyError(); | |
for (uint i = 0; i < 16; i++) | |
{ | |
var result = new System.Text.StringBuilder((int)64); | |
OpenVR.System.GetStringTrackedDeviceProperty(i, ETrackedDeviceProperty.Prop_RenderModelName_String, result, 64, ref error); | |
// if you want to get first tracker's index. | |
if (result.ToString().Contains("tracker")) | |
{ | |
index = i; | |
break; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment