基础内容
必要插件安装 缓动曲线和动画基础 ElementFolder,Track与其次级模块,PathNode重构
This commit is contained in:
38
Assets/Modern UI Pack/Scripts/Window/WindowManagerButton.cs
Normal file
38
Assets/Modern UI Pack/Scripts/Window/WindowManagerButton.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Michsky.MUIP
|
||||
{
|
||||
[RequireComponent(typeof(Animator))]
|
||||
public class WindowManagerButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
public bool enableMobileMode = false;
|
||||
[HideInInspector] public Animator buttonAnimator;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (buttonAnimator == null) { buttonAnimator = gameObject.GetComponent<Animator>(); }
|
||||
if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.Android) { enableMobileMode = true; }
|
||||
}
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
if (enableMobileMode == true)
|
||||
return;
|
||||
|
||||
if (!buttonAnimator.GetCurrentAnimatorStateInfo(0).IsName("Hover to Pressed")
|
||||
&& !buttonAnimator.GetCurrentAnimatorStateInfo(0).IsName("Normal to Pressed"))
|
||||
buttonAnimator.Play("Normal to Hover");
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
if (enableMobileMode == true)
|
||||
return;
|
||||
|
||||
if (!buttonAnimator.GetCurrentAnimatorStateInfo(0).IsName("Hover to Pressed")
|
||||
&& !buttonAnimator.GetCurrentAnimatorStateInfo(0).IsName("Normal to Pressed"))
|
||||
buttonAnimator.Play("Hover to Normal");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user