FCameraManagerEvent.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using UnityEngine;
  2. using System.Collections.Generic;
  3. namespace Flux
  4. {
  5. //[FEvent("Camera/Camera Manager")]
  6. public class FCameraManagerEvent : FEvent {
  7. [Tooltip("Camera that should become active")]
  8. [SerializeField]
  9. private Camera _camera = null;
  10. public Camera Camera { get { return _camera; } set { _camera = value; } }
  11. protected override void OnInit ()
  12. {
  13. // only one of the events will turn off all the cameras at the start
  14. // this is simply to not have a camera manager track which would only have to do this
  15. if( GetId() == 0 )
  16. {
  17. List<FEvent> events = Track.Events;
  18. foreach( FCameraManagerEvent evt in events )
  19. if( evt.Camera != null )
  20. evt.Camera.gameObject.SetActive( false );
  21. }
  22. }
  23. protected override void OnTrigger( float timeSinceTrigger )
  24. {
  25. _camera.gameObject.SetActive( true );
  26. }
  27. protected override void OnFinish()
  28. {
  29. _camera.gameObject.SetActive( false );
  30. }
  31. public override string Text {
  32. get {
  33. return _camera == null ? "!Missing!" : _camera.name;
  34. }
  35. set {
  36. // cannot set
  37. }
  38. }
  39. }
  40. }