Skip to content

Instantly share code, notes, and snippets.

@hon454
Created November 6, 2017 16:02
Show Gist options
  • Save hon454/57ba590a4f3f33d6172f9c1d7f60ad32 to your computer and use it in GitHub Desktop.
Save hon454/57ba590a4f3f33d6172f9c1d7f60ad32 to your computer and use it in GitHub Desktop.
[SteamVR][Unity] Get tracked object name
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