LocalPositionEffect.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.EventSystems;
  5. using DG.Tweening;
  6. using System;
  7. namespace SC
  8. {
  9. public class LocalPositionEffect : PointEffectBase {
  10. /// <summary>
  11. /// 初始值
  12. /// </summary>
  13. float initLocalPositionValue;
  14. /// <summary>
  15. /// 开始值
  16. /// </summary>
  17. public float LocalPositionValue;
  18. protected override void Awake() {
  19. base.Awake();
  20. initLocalPositionValue = transform.localPosition.z;
  21. }
  22. public override void OnPointerEnter(PointerEventData eventData) {
  23. base.OnPointerEnter(eventData);
  24. transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, LocalPositionValue);
  25. }
  26. public override void OnPointerExit(PointerEventData eventData) {
  27. base.OnPointerExit(eventData);
  28. transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, initLocalPositionValue);
  29. }
  30. }
  31. }