ListButtonEffect.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using DG.Tweening;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7. public class ListButtonEffect : MonoBehaviour
  8. {
  9. public Vector3 v3Pos;
  10. public int index;
  11. // Start is called before the first frame update
  12. void Start()
  13. {
  14. }
  15. public void showMove()
  16. {
  17. if (v3Pos == Vector3.zero)
  18. v3Pos = this.transform.localPosition;
  19. LeanTween.moveLocal(this.gameObject, v3Pos, 0.25f);
  20. }
  21. public void hideMove()
  22. {
  23. LeanTween.moveLocal(this.gameObject,Vector3.zero,0.25f);
  24. }
  25. public void showEffect()
  26. {
  27. GameEffect.setAlpha(this.gameObject, 1, 0.25f);
  28. }
  29. public void hideEffect(Action<GameObject> callback=null)
  30. {
  31. GameEffect.setAlpha(this.gameObject, 0, 0.25f, callback);
  32. }
  33. private void OnEnable()
  34. {
  35. if (v3Pos == Vector3.zero)
  36. v3Pos = this.transform.localPosition;
  37. // Invoke("showEffect", 0.1f);
  38. showEffect();
  39. }
  40. // Update is called once per frame
  41. void Update()
  42. {
  43. }
  44. }