SFX_MouseControlledObjectLauncher.cs 871 B

123456789101112131415161718192021222324252627282930
  1. using UnityEngine;
  2. using UnityEngine.Serialization;
  3. // ReSharper disable once CheckNamespace
  4. namespace QFX.SFX
  5. {
  6. public class SFX_MouseControlledObjectLauncher : MonoBehaviour
  7. {
  8. public SFX_ControlledObject[] ControlledObjects;
  9. public int MouseButtonCode;
  10. public bool CallStop = true;
  11. private void Update()
  12. {
  13. if (Input.GetMouseButtonDown(MouseButtonCode))
  14. {
  15. foreach (var controlledObject in ControlledObjects)
  16. {
  17. controlledObject.Setup();
  18. controlledObject.Run();
  19. }
  20. }
  21. else if (CallStop && Input.GetMouseButtonUp(MouseButtonCode))
  22. {
  23. foreach (var controlledObject in ControlledObjects)
  24. controlledObject.Stop();
  25. }
  26. }
  27. }
  28. }