鸟语天空
事件系统(UnityEngine.EventSystems)
post by:追风剑情 2021-12-11 19:02

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)
    {
        
    }
}

评论:
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容