UIDragCamera.cs 906 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using UnityEngine;
  3. [ExecuteInEditMode]
  4. [AddComponentMenu("NGUI/Interaction/Drag Camera")]
  5. public class UIDragCamera : MonoBehaviour
  6. {
  7. private void Awake()
  8. {
  9. if (this.draggableCamera == null)
  10. {
  11. this.draggableCamera = NGUITools.FindInParents<UIDraggableCamera>(base.gameObject);
  12. }
  13. }
  14. private void OnPress(bool isPressed)
  15. {
  16. if (base.enabled && NGUITools.GetActive(base.gameObject) && this.draggableCamera != null)
  17. {
  18. this.draggableCamera.Press(isPressed);
  19. }
  20. }
  21. private void OnDrag(Vector2 delta)
  22. {
  23. if (base.enabled && NGUITools.GetActive(base.gameObject) && this.draggableCamera != null)
  24. {
  25. this.draggableCamera.Drag(delta);
  26. }
  27. }
  28. private void OnScroll(float delta)
  29. {
  30. if (base.enabled && NGUITools.GetActive(base.gameObject) && this.draggableCamera != null)
  31. {
  32. this.draggableCamera.Scroll(delta);
  33. }
  34. }
  35. public UIDraggableCamera draggableCamera;
  36. }