SteamVRTrack.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using Newtonsoft.Json;
  5. using UnityEngine;
  6. using Valve.VR;
  7. public class SteamVRTrack : TrackpointMesh
  8. {
  9. public string filePath;
  10. private GameObject meshObject;
  11. private TrackpointMesh trackpointMesh;
  12. private SteamVR_TrackedObject tracking;
  13. // Start is called before the first frame update
  14. void Start()
  15. {
  16. meshObject = new GameObject();
  17. trackpointMesh = meshObject.AddComponent<TrackpointMesh>();
  18. trackpointMesh.transform.parent = this.transform;
  19. trackpointMesh.setup(filePath, TrackingSystem.SteamVRTrack);
  20. setupTrackpointTranslationAndRotation();
  21. tracking = gameObject.AddComponent<SteamVR_TrackedObject>();
  22. tracking.index = (SteamVR_TrackedObject.EIndex)1;
  23. }
  24. void setupTrackpointTranslationAndRotation()
  25. {
  26. string metadata = trackpointMesh.getMetaData(TrackingSystem.SteamVRTrack);
  27. trackpointMesh.transform.localPosition = new Vector3(0.0f, 0.0f, 3.0f);
  28. }
  29. }