【发布时间】:2019-03-28 07:32:36
【问题描述】:
我有 2 个预制对象组成一个面板,里面有 UI.Text。一个包含拖放类,另一个包含拖放类。但是,即使拖动工作正常,也永远不会执行 OnDrop() 函数。我还在添加到主 Canvas 的 CanvasGroup 中将 blockRaycasts 设置为 false。
GetComponentInParent<CanvasGroup>().blocksRaycasts = false;
当我将对象拖入其中时,从 UnityEngine.EventSystems.IDropHandler 接口实现的方法 OnDrop() 是否有任何原因可能不会触发?
public class ItemDropHandler : MonoBehaviour, IDropHandler
{
public void OnDrop(PointerEventData eventData)
{
Debug.Log("Drop detected over the UI.Text"); //this is never shown
}
}
【问题讨论】:
标签: c# unity3d drag-and-drop