首页 > 解决方案 > MouseEnter()、MouseExit() 和 MouseUp() 仅统一触发一次

问题描述

我正在尝试在我的Unity项目中创建一个棘手的板条箱。

问题是Unity只检测variables一次这些,而玩家应该能够hover按照他们的意愿打开和关闭板条箱。

代码在其中输出这些值,DebugLog但是它们仅在第一次执行时才起作用。

提前致谢

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

public class Detection : MonoBehaviour {


     void OnMouseOver()
    {
        Debug.Log("Enter");
    }

     void OnMouseExit()
    {
        Debug.Log("Exit");
    }

     void OnMouseUp()
    {
        Debug.Log("Pressed");
    }

}

标签: c#unity3d

解决方案


推荐阅读