Cute_demon_attacks/meng_yao/Assets/script/JumpScene/SilderUI.cs

57 lines
1.1 KiB
C#
Raw Normal View History

2024-10-30 01:08:16 +08:00
using UnityEngine;
using UnityEngine.EventSystems;
using DG.Tweening;
using System.Collections.Generic;
public class SilderUI : MonoBehaviour, IDragHandler, IEndDragHandler
{
public SceneBtn sceneBtn;
private float swipeThreshold = 10f; // <20><><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>ֵ
private void Start()
{
}
public void OnDrag(PointerEventData eventData)
{
}
public void OnEndDrag(PointerEventData eventData)
{
float dragDistance = eventData.pressPosition.x - eventData.position.x;
Debug.Log(dragDistance);
bool toNext = dragDistance > 0; // <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>
if (toNext)
{
JumpScene.jumpbool += 1;
}
else
{
JumpScene.jumpbool -= 1;
}
if (JumpScene.jumpbool < 0)
{
JumpScene.jumpbool = 4;
}
if (JumpScene.jumpbool >4)
{
JumpScene.jumpbool = 0;
}
2024-10-31 20:40:09 +08:00
if (Mathf.Abs(dragDistance) >= swipeThreshold)
{
sceneBtn.BeginLoad(JumpScene.jumpbool);
}
2024-10-30 01:08:16 +08:00
}
}