事件系统(UnityEngine.EventSystems)

作者:追风剑情 发布于:2021-12-11 19:02 分类:Unity3d

https://docs.unity3d.com/Packages/com.unity.ugui@1.0/api/UnityEngine.EventSystems.html

注意:非UGUI元素要响应事件,需要在 Camera 上添加 PhysicsRaycaster 组件。

using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;

public class TestButton : MonoBehaviour, IPointerClickHandler, IPointerDownHandler, IPointerUpHandler
{
    public void OnPointerClick(PointerEventData eventData)
    {
        
    }

    public void OnPointerDown(PointerEventData eventData)
    {
        
    }

    public void OnPointerUp(PointerEventData eventData)
    {
        
    }
}

标签: Unity3d

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号