47 lines
957 B
C#
47 lines
957 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class SwipeController : MonoBehaviour
|
|
{
|
|
[SerializeField] int maxPage;
|
|
int currentPage;
|
|
Vector3 targetPos;
|
|
[SerializeField] Vector3 pageStep;
|
|
[SerializeField] RectTransform materiPageRect;
|
|
|
|
[SerializeField] float tweenTime;
|
|
[SerializeField] LeanTweenType tweenType;
|
|
|
|
|
|
public void Awake()
|
|
{
|
|
currentPage = 1;
|
|
targetPos = materiPageRect.localPosition;
|
|
}
|
|
public void Next()
|
|
{
|
|
if (currentPage < maxPage)
|
|
{
|
|
currentPage++;
|
|
targetPos += pageStep;
|
|
MovePage();
|
|
}
|
|
}
|
|
|
|
public void Previous()
|
|
{
|
|
if (currentPage > 1)
|
|
{
|
|
currentPage--;
|
|
targetPos -= pageStep;
|
|
MovePage();
|
|
}
|
|
}
|
|
|
|
void MovePage()
|
|
{
|
|
materiPageRect.LeanMoveLocal(targetPos,tweenTime).setEase(tweenType);
|
|
}
|
|
}
|