quick-cocos-lua 中menu嵌套ScrollView点击按钮不能进行拖动
1条回答 默认 最新
- qq_41990768 2018-05-15 12:57关注
将脚本挂载在ScrollView结构下需要响应时间的对象上
[csharp] view plain copy
using UnityEngine.UI;
using UnityEngine.EventSystems;
using UnityEngine;public class GDragEventDispatcher : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{ScrollRect anotherScrollRect; private Image thisRaycast; void Awake() { //FindScrollRect(gameObject); //if (anotherScrollRect) //{ // thisRaycast = gameObject.GetComponent<Image>(); //} } void Start() { FindScrollRect(gameObject); if (anotherScrollRect) { thisRaycast = gameObject.GetComponent<Image>(); } } private void FindScrollRect(GameObject obj) { GameObject tempObj = obj.transform.parent.gameObject; //Debug.Log("测试"+tempObj.gameObject.name); anotherScrollRect = tempObj.GetComponent<ScrollRect>(); if (anotherScrollRect) { //Debug.Log(anotherScrollRect.gameObject.name); return; } else { FindScrollRect(tempObj); } } public void OnBeginDrag(PointerEventData eventData) { if (anotherScrollRect) { anotherScrollRect.OnBeginDrag(eventData); } if (thisRaycast) { thisRaycast.raycastTarget = false; } } public void OnDrag(PointerEventData eventData) { if (anotherScrollRect) { anotherScrollRect.OnDrag(eventData); } } public void OnEndDrag(PointerEventData eventData) { if (anotherScrollRect) { anotherScrollRect.OnEndDrag(eventData); } if (thisRaycast) { thisRaycast.raycastTarget = true; } }
}
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
- ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
- ¥20 有关区间dp的问题求解
- ¥15 多电路系统共用电源的串扰问题
- ¥15 slam rangenet++配置
- ¥15 有没有研究水声通信方面的帮我改俩matlab代码
- ¥15 ubuntu子系统密码忘记
- ¥15 保护模式-系统加载-段寄存器
- ¥15 电脑桌面设定一个区域禁止鼠标操作
- ¥15 求NPF226060磁芯的详细资料