繁体   English   中英

Unity 按钮 hover animation 在场景开始时播放,而不是在鼠标指针悬停在游戏对象上时播放

[英]Unity button hover animation plays when the scene starts, not when the mouse pointer is over the gameobject

ive made a hoveron and hoveroff animation which when the mouse pointer is over the button (hovering) it slides the button out slightly to the left, and hover off the opposite animation where it slides back to its original position.

但是当场景开始时它会播放悬停,我根本无法播放悬停,有人知道解决方法吗?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

public class hoverscript : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
    public RectTransform NewGameMenuButton;

    // Start is called before the first frame update
    void Start()
    {
    NewGameMenuButton.GetComponent<Animator>().Play("Hover Off");
    }

    public void OnPointerEnter(PointerEventData eventData)
    {
        NewGameMenuButton.GetComponent<Animator>().Play("Hover On");
    
    }

     public void OnPointerExit(PointerEventData eventData)
    {
        NewGameMenuButton.GetComponent<Animator>().Play("Hover Off");
  
    }
}

按钮本身

好的解决方法是我没有拖动脚本上的按钮 IM STUPID SORRY!!!!!!!!!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM