ButtonEffect.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using XRTool.Util;
  5. public class ButtonEffect : MonoBehaviour
  6. {
  7. bool isUp=false;
  8. public GameObject button;
  9. Vector3 localV3;
  10. public Transform BtnTip;
  11. public void buttonEnter()
  12. {
  13. if(!isUp)
  14. {
  15. LeanTween.cancel(button.gameObject);
  16. LeanTween.scale(button.gameObject, localV3 * 1.1f, 0.2f);
  17. }
  18. if (BtnTip)
  19. {
  20. BtnTip.gameObject.SetActive(true);
  21. }
  22. }
  23. public void buttonExit()
  24. {
  25. if (!isUp)
  26. {
  27. LeanTween.cancel(button.gameObject);
  28. LeanTween.scale(button.gameObject, localV3, 0.4f);
  29. }
  30. if (BtnTip)
  31. {
  32. BtnTip.gameObject.SetActive(false);
  33. }
  34. }
  35. public void buttonDown()
  36. {
  37. LeanTween.cancel(button.gameObject);
  38. LeanTween.scale(button.gameObject, localV3 * 0.9f, 0.2f);
  39. }
  40. public void buttonUp()
  41. {
  42. LeanTween.cancel(button.gameObject);
  43. LeanTween.scale(button.gameObject, localV3 * 1.5f, 0.25f);
  44. isUp = true;
  45. // UIModelManager.Instance.ZYKOnClick(true);
  46. }
  47. private void OnEnable()
  48. {
  49. isUp = false;
  50. if (localV3==Vector3.zero)
  51. localV3 = button.transform.localScale;
  52. button.transform.localScale = localV3 * 2.5f;
  53. LeanTween.cancel(button.gameObject);
  54. LeanTween.scale(button.gameObject, localV3, 0.4f);
  55. }
  56. }