RouteManager.cs 903 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using UnityEditor;
  3. using UnityEngine;
  4. using Valve.VR.InteractionSystem;
  5. namespace Routes
  6. {
  7. public class RouteManager : MonoBehaviour
  8. {
  9. public Route[] routes;
  10. public int selectedRoute;
  11. private void Awake()
  12. {
  13. ShowActiveRoute();
  14. }
  15. private void ShowActiveRoute()
  16. {
  17. routes.ForEach(r => r.Clear());
  18. routes[selectedRoute].Show(); //TODO: maybe show when coming to it
  19. }
  20. private void OnValidate()
  21. {
  22. ChangeActiveRoute();
  23. if (EditorApplication.isPlaying)
  24. {
  25. ShowActiveRoute();
  26. }
  27. }
  28. private void ChangeActiveRoute()
  29. {
  30. for (int i = 0; i < routes.Length; i++)
  31. {
  32. routes[i].gameObject.SetActive(i == selectedRoute);
  33. }
  34. }
  35. }
  36. }