TrackablePlaneGenerator.cs 877 B

1234567891011121314151617181920212223242526272829303132
  1. using SC.XR.Unity;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using TMPro;
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7. public class TrackablePlaneGenerator : MonoBehaviour
  8. {
  9. public GameObject trackablePlanePrefab;
  10. private List<PlaneTrackable> newPlanes = new List<PlaneTrackable>();
  11. public Text text;
  12. public void Update()
  13. {
  14. if (!GSXRManager.Instance.Initialized)
  15. {
  16. return;
  17. }
  18. text.text = API_GSXR_Slam.GSXR_Get_PanelNum().ToString();
  19. TrackableManager.Instance.GetTrackables<PlaneTrackable>(newPlanes, TrackableQueryFilter.New);
  20. for (int i = 0; i < newPlanes.Count; i++)
  21. {
  22. GameObject trackablePlaneGameObject = Instantiate(trackablePlanePrefab);
  23. trackablePlaneGameObject.GetComponent<TrackablePlaneMono>().Init(newPlanes[i]);
  24. }
  25. }
  26. }