Unity-OnBeginDrag/OnDrag e.t.c无法正常工作 [英] Unity - OnBeginDrag / OnDrag e.t.c not working

查看:594
本文介绍了Unity-OnBeginDrag/OnDrag e.t.c无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使以下代码起作用:

Trying to get the following code to work:

public void OnBeginDrag(PointerEventData eventData)
{
    if (item.ID != -1)
    {
        transform.position = eventData.position;
    }

}

忽略item.ID!= -1,我确定这不是问题所在,因为无论如何,它都不起作用.

Ignore item.ID != -1, I know for sure that's not the issue because it doesn't work no matter what the condition.

我需要知道的是,是否需要启用画布或图像中的某个设置(此脚本附加到面板内的图像上)才能使交互起作用.我本该宣誓要启用鼠标才能在画布上工作.

What I need to know is if there is a setting in the canvas or in the image (this script is attached to an image inside a panel) that needs to be enabled to get interaction to work. I could've sworn there was something that needs to be enabled to get the mouse working with the canvas.

谢谢

推荐答案

已解决:需要添加图形Raycaster.

SOLVED: Needed to add a Graphic Raycaster.

这篇关于Unity-OnBeginDrag/OnDrag e.t.c无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆