LobbyUI 슬라이드 구조 적용
This commit is contained in:
50
Gameton-06/Assets/Gameton/Scripts/UI/SwipeController.cs
Normal file
50
Gameton-06/Assets/Gameton/Scripts/UI/SwipeController.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TON
|
||||
{
|
||||
public class SwipeController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] int maxPage;
|
||||
|
||||
[SerializeField] int currentPage;
|
||||
[SerializeField] Vector2 targetPos;
|
||||
[SerializeField] Vector2 pageStep;
|
||||
[SerializeField] RectTransform levelPagesRect;
|
||||
[SerializeField] float tweenTime;
|
||||
[SerializeField] LeanTweenType tweenType;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
currentPage = 1;
|
||||
targetPos = levelPagesRect.localPosition;
|
||||
}
|
||||
|
||||
public void Next()
|
||||
{
|
||||
if (currentPage < maxPage)
|
||||
{
|
||||
currentPage++;
|
||||
targetPos += pageStep;
|
||||
MovePage();
|
||||
}
|
||||
}
|
||||
|
||||
public void Previous()
|
||||
{
|
||||
if (currentPage > 1)
|
||||
{
|
||||
currentPage--;
|
||||
targetPos -= pageStep;
|
||||
MovePage();
|
||||
}
|
||||
}
|
||||
|
||||
public void MovePage()
|
||||
{
|
||||
levelPagesRect.LeanMoveLocal(targetPos, tweenTime).setEase(tweenType);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user