ButtonEffect.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 * 2.5f, 0.25f);
  44. isUp = true;
  45. }
  46. private void OnEnable()
  47. {
  48. isUp = false;
  49. if (localV3==Vector3.zero)
  50. localV3 = button.transform.localScale;
  51. button.transform.localScale = localV3 * 2.5f;
  52. LeanTween.cancel(button.gameObject);
  53. LeanTween.scale(button.gameObject, localV3, 0.4f);
  54. }
  55. }