PlaybackController.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using UnityEngine;
  2. [DefaultExecutionOrder(50)]
  3. public class PlaybackController : MonoBehaviour
  4. {
  5. private Component[] years;
  6. // Change Cameras
  7. public Camera cam1;
  8. public Camera cam2;
  9. private void Start()
  10. {
  11. cam1.enabled = true;
  12. cam2.enabled = false;
  13. years = gameObject.GetComponentsInChildren<WalkLerpPlayback>();
  14. foreach(var year in years)
  15. {
  16. year.GetComponent<WalkLerpPlayback>().rewind = false;
  17. year.GetComponent<WalkLerpPlayback>().pause = false;
  18. year.GetComponent<WalkLerpPlayback>().play = false;
  19. }
  20. }
  21. public void OnRewindPress()
  22. {
  23. foreach (var year in years)
  24. {
  25. if (!year.GetComponent<WalkLerpPlayback>().rewind)
  26. {
  27. year.GetComponent<WalkLerpPlayback>().rewind = true;
  28. year.GetComponent<WalkLerpPlayback>().pause = false;
  29. year.GetComponent<WalkLerpPlayback>().play = false;
  30. }
  31. }
  32. }
  33. public void OnPausePress()
  34. {
  35. foreach (var year in years)
  36. {
  37. if (!year.GetComponent<WalkLerpPlayback>().pause)
  38. {
  39. year.GetComponent<WalkLerpPlayback>().rewind = false;
  40. year.GetComponent<WalkLerpPlayback>().pause = true;
  41. year.GetComponent<WalkLerpPlayback>().play = false;
  42. }
  43. }
  44. }
  45. public void OnPlayPress()
  46. {
  47. foreach (var year in years)
  48. {
  49. if (!year.GetComponent<WalkLerpPlayback>().play)
  50. {
  51. year.GetComponent<WalkLerpPlayback>().rewind = false;
  52. year.GetComponent<WalkLerpPlayback>().pause = false;
  53. year.GetComponent<WalkLerpPlayback>().play = true;
  54. }
  55. }
  56. }
  57. public void OnValueChanged(float value)
  58. {
  59. // This Method is not needed, bc the value is taken from the slider directly.
  60. }
  61. public void OnChangeViewClicked()
  62. {
  63. cam1.enabled = !cam1.enabled;
  64. cam2.enabled = !cam2.enabled;
  65. }
  66. }