unity如果两个ScrollRect嵌套在一起,后面的辉挡住前面的。可以依靠滑动的方向是否和滑动区域一只,如果在横向区域操作竖向滑行,事件将抛给父列表
如图
脚本代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class CustomScrollRect :ScrollRect {
//父CustomScrollRect对象
private CustomScrollRect m_Parent;
public enum Direction
{
Horizontal,
Vertical
}
//滑动方向
private Direction m_Direction = Direction.Horizontal;
//当前操作方向
private Direction m_BeginDragDirection = Direction.Horizontal;
protected override void Awa