架构大更
This commit is contained in:
@@ -6,12 +6,6 @@ namespace Michsky.MUIP
|
||||
[RequireComponent(typeof(Animator))]
|
||||
public class AnimatedIconHandler : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
|
||||
{
|
||||
[Header("Settings")]
|
||||
public PlayType playType;
|
||||
public Animator iconAnimator;
|
||||
|
||||
bool isClicked;
|
||||
|
||||
public enum PlayType
|
||||
{
|
||||
Click,
|
||||
@@ -19,21 +13,18 @@ namespace Michsky.MUIP
|
||||
None
|
||||
}
|
||||
|
||||
void Start()
|
||||
[Header("Settings")] public PlayType playType;
|
||||
|
||||
public Animator iconAnimator;
|
||||
|
||||
private bool isClicked;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (iconAnimator == null)
|
||||
iconAnimator = gameObject.GetComponent<Animator>();
|
||||
}
|
||||
|
||||
public void PlayIn() { iconAnimator.Play("In"); }
|
||||
public void PlayOut() { iconAnimator.Play("Out"); }
|
||||
|
||||
public void ClickEvent()
|
||||
{
|
||||
if (isClicked == true) { PlayOut(); isClicked = false; }
|
||||
else { PlayIn(); isClicked = true; }
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (playType == PlayType.Click)
|
||||
@@ -51,5 +42,29 @@ namespace Michsky.MUIP
|
||||
if (playType == PlayType.Hover)
|
||||
iconAnimator.Play("Out");
|
||||
}
|
||||
|
||||
public void PlayIn()
|
||||
{
|
||||
iconAnimator.Play("In");
|
||||
}
|
||||
|
||||
public void PlayOut()
|
||||
{
|
||||
iconAnimator.Play("Out");
|
||||
}
|
||||
|
||||
public void ClickEvent()
|
||||
{
|
||||
if (isClicked)
|
||||
{
|
||||
PlayOut();
|
||||
isClicked = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayIn();
|
||||
isClicked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user