源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

93 lines
2.2 KiB

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using LuaInterface;
using LuaFramework;
using System;
using UnityEngine.EventSystems;
public class VHScrollRect : ScrollRect
{
public ScrollRect parentScroll;
public bool isVertical = false;
private bool isSelf = false;
public override void OnBeginDrag(PointerEventData eventData)
{
Vector2 touchDeltaPosition;
#if (UNITY_ANDROID || UNITY_IPHONE) && !UNITY_EDITOR
touchDeltaPosition = Input.GetTouch(0).deltaPosition;
#else
float delta_x = Input.GetAxis("Mouse X");
float delta_y = Input.GetAxis("Mouse Y");
touchDeltaPosition = new Vector2(delta_x, delta_y);
#endif
if (isVertical)
{
if (Mathf.Abs(touchDeltaPosition.x) < Mathf.Abs(touchDeltaPosition.y))
{
isSelf = true;
base.OnBeginDrag(eventData);
}
else
{
isSelf = false;
if(parentScroll){
parentScroll.OnBeginDrag(eventData);
}
}
}
else
{
if (Mathf.Abs(touchDeltaPosition.x) > Mathf.Abs(touchDeltaPosition.y))
{
isSelf = true;
base.OnBeginDrag(eventData);
}
else
{
isSelf = false;
if(parentScroll){
parentScroll.OnBeginDrag(eventData);
}
}
}
}
public override void OnDrag(PointerEventData eventData)
{
if (isSelf)
{
base.OnDrag(eventData);
}
else
{
if(parentScroll){
parentScroll.OnDrag(eventData);
}
}
}
public override void OnEndDrag(PointerEventData eventData)
{
if (isSelf)
{
base.OnEndDrag(eventData);
}
else
{
if(parentScroll){
parentScroll.OnEndDrag(eventData);
}
}
}
}