1029 lines
29 KiB
C#
1029 lines
29 KiB
C#
|
|
using LuaInterface;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.EventSystems;
|
|||
|
|
using UnityEngine.UI;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
|
|||
|
|
public class PageSliderManager : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
|
|||
|
|
{
|
|||
|
|
[Header("ҳ<><D2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")]
|
|||
|
|
[SerializeField] private Transform[] pageTitle;
|
|||
|
|
[SerializeField] private Animator[] pageAnimator;
|
|||
|
|
[SerializeField] private Transform[] pages; // <20><><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>Transform<72><6D><EFBFBD><EFBFBD>
|
|||
|
|
[SerializeField] private int currentPageIndex = 0; // <20><>ǰҳ<C7B0><D2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")]
|
|||
|
|
[SerializeField] private float snapSpeed = 15f; // <20><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
|
|||
|
|
[SerializeField] private float snapThreshold = 0.3f; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD><EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
[Header("UI<55><49><EFBFBD><EFBFBD>")]
|
|||
|
|
[SerializeField] private Graphic dragArea; // <20><><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD>UI<55><49><EFBFBD><EFBFBD>
|
|||
|
|
[SerializeField] private bool requireExactClick = true; // <20>Ƿ<EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Image<67><65>
|
|||
|
|
|
|||
|
|
// ˽<>б<EFBFBD><D0B1><EFBFBD>
|
|||
|
|
private float pageSpacing = 0f; // ҳ<><D2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
private bool isDragging = false;
|
|||
|
|
private bool dragValid = false; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ק<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ч
|
|||
|
|
|
|||
|
|
// <20>϶<EFBFBD><CFB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼
|
|||
|
|
private Vector3 dragStartPosition; // <20>϶<EFBFBD><CFB6><EFBFBD>ʼʱ<CABC><CAB1>λ<EFBFBD><CEBB>
|
|||
|
|
private Vector2 pageDownPosition; // ҳ<>水<EFBFBD><E6B0B4>ʱ<EFBFBD><CAB1>λ<EFBFBD><CEBB>
|
|||
|
|
private float totalDragDistance = 0f;
|
|||
|
|
|
|||
|
|
private Animator animDown;
|
|||
|
|
private Animator animLast;
|
|||
|
|
private Animator animNext;
|
|||
|
|
private EnumDistance disAnimMove = EnumDistance.None;
|
|||
|
|
private float animTimeDown;
|
|||
|
|
private float animTimeLast;
|
|||
|
|
private float animTimeNext;
|
|||
|
|
private int recordPage = -1;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ٶȼ<D9B6><C8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><D8B1><EFBFBD>
|
|||
|
|
private Vector3 lastDragPosition;
|
|||
|
|
private float dragSpeed;
|
|||
|
|
private float dragDirection;
|
|||
|
|
|
|||
|
|
// <20><>˽<EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
private JumpMode currentJumpMode = JumpMode.Animated;
|
|||
|
|
private int jumpTargetIndex = -1;
|
|||
|
|
private float jumpProgress = 0f;
|
|||
|
|
private float jumpDuration = 0.3f; // <20><>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
private float jumpStartX = 0f; // <20><><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD>¼<EFBFBD><C2BC>ת<EFBFBD><D7AA>ʼλ<CABC><CEBB>
|
|||
|
|
private float jumpTargetX = 0f; // <20><><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD>¼<EFBFBD><C2BC>תĿ<D7AA><C4BF>λ<EFBFBD><CEBB>
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD>תģʽö<CABD><C3B6>
|
|||
|
|
private enum JumpMode
|
|||
|
|
{
|
|||
|
|
Direct, // ֱ<><D6B1><EFBFBD><EFBFBD>ת
|
|||
|
|
Animated // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>״̬
|
|||
|
|
private enum SlideState
|
|||
|
|
{
|
|||
|
|
Idle, // <20><><EFBFBD><EFBFBD>
|
|||
|
|
Dragging, // <20>϶<EFBFBD><CFB6><EFBFBD>
|
|||
|
|
Snapping, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
Momentum // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
}
|
|||
|
|
private SlideState currentState = SlideState.Idle;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>
|
|||
|
|
private bool isAnimationsComplete = true;
|
|||
|
|
|
|||
|
|
private void Start()
|
|||
|
|
{
|
|||
|
|
CalculatePageSpacing();
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ק<EFBFBD><D7A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD>ǰGameObject<63><74>Graphic<69><63><EFBFBD><EFBFBD>
|
|||
|
|
if (dragArea == null)
|
|||
|
|
{
|
|||
|
|
dragArea = GetComponent<Graphic>();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ק<EFBFBD><D7A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (dragArea != null)
|
|||
|
|
{
|
|||
|
|
dragArea.raycastTarget = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void SetTitleSpacing(LuaTable table)
|
|||
|
|
{
|
|||
|
|
Transform[] transTemp = new Transform[table.Length + 1];
|
|||
|
|
pageAnimator = new Animator[table.Length + 1];
|
|||
|
|
for (int i = 0; i < transTemp.Length; i++)
|
|||
|
|
{
|
|||
|
|
transTemp[i] = table.RawGetIndex<Transform>(i);
|
|||
|
|
pageAnimator[i] = transTemp[i].GetChild(0).GetComponent<Animator>();
|
|||
|
|
}
|
|||
|
|
pageTitle = transTemp;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void CalculatePageSpacing()
|
|||
|
|
{
|
|||
|
|
if (pages == null || pages.Length < 2)
|
|||
|
|
{
|
|||
|
|
pageSpacing = Screen.width;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Vector3 page1Pos = pages[0].localPosition;
|
|||
|
|
Vector3 page2Pos = pages[1].localPosition;
|
|||
|
|
pageSpacing = Mathf.Abs(page2Pos.x - page1Pos.x);
|
|||
|
|
|
|||
|
|
if (pageSpacing < 1f)
|
|||
|
|
{
|
|||
|
|
pageSpacing = Screen.width;
|
|||
|
|
RearrangePages();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void RearrangePages()
|
|||
|
|
{
|
|||
|
|
for (int i = 0; i < pages.Length; i++)
|
|||
|
|
{
|
|||
|
|
if (pages[i] == null) continue;
|
|||
|
|
float xPos = i * pageSpacing;
|
|||
|
|
pages[i].localPosition = new Vector3(xPos, 0, 0);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void Update()
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>ת
|
|||
|
|
if (currentJumpMode == JumpMode.Direct && jumpTargetIndex >= 0)
|
|||
|
|
{
|
|||
|
|
HandleDirectJump();
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (currentState == SlideState.Snapping)
|
|||
|
|
{
|
|||
|
|
SmoothToTarget();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (currentState != SlideState.Dragging && currentState != SlideState.Snapping)
|
|||
|
|
{
|
|||
|
|
UpdateCurrentPageIndex();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>鶯<EFBFBD><E9B6AF><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CheckAnimationsComplete();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>ת<EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>
|
|||
|
|
private void HandleDirectJump()
|
|||
|
|
{
|
|||
|
|
if (jumpProgress >= 1f)
|
|||
|
|
{
|
|||
|
|
// <20><>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>
|
|||
|
|
currentJumpMode = JumpMode.Animated;
|
|||
|
|
jumpTargetIndex = -1;
|
|||
|
|
currentState = SlideState.Idle;
|
|||
|
|
|
|||
|
|
// ȷ<><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>ȷ
|
|||
|
|
Vector3 tempNewPos = pages[0].localPosition;
|
|||
|
|
tempNewPos.x = jumpTargetX;
|
|||
|
|
pages[0].localPosition = tempNewPos;
|
|||
|
|
|
|||
|
|
// ͬ<><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>
|
|||
|
|
for (int i = 1; i < pages.Length; i++)
|
|||
|
|
{
|
|||
|
|
if (pages[i] == null) continue;
|
|||
|
|
Vector3 pos = tempNewPos + new Vector3(i * pageSpacing, 0, 0);
|
|||
|
|
pages[i].localPosition = pos;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ȷ<><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC>ȷ
|
|||
|
|
EnsureFinalAnimationStates();
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>
|
|||
|
|
jumpProgress += Time.deltaTime / jumpDuration;
|
|||
|
|
jumpProgress = Mathf.Clamp01(jumpProgress);
|
|||
|
|
|
|||
|
|
// ʹ<>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
float t = EaseOutCubic(jumpProgress);
|
|||
|
|
float currentX = Mathf.Lerp(jumpStartX, jumpTargetX, t);
|
|||
|
|
|
|||
|
|
// Ӧ<><D3A6><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|||
|
|
Vector3 newPos = pages[0].localPosition;
|
|||
|
|
newPos.x = currentX;
|
|||
|
|
pages[0].localPosition = newPos;
|
|||
|
|
|
|||
|
|
// ͬ<><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>
|
|||
|
|
for (int i = 1; i < pages.Length; i++)
|
|||
|
|
{
|
|||
|
|
if (pages[i] == null) continue;
|
|||
|
|
Vector3 pos = newPos + new Vector3(i * pageSpacing, 0, 0);
|
|||
|
|
pages[i].localPosition = pos;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>η<EFBFBD><CEB7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
private float EaseOutCubic(float t)
|
|||
|
|
{
|
|||
|
|
t -= 1;
|
|||
|
|
return t * t * t + 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// IBeginDragHandler<65>ӿ<EFBFBD>ʵ<EFBFBD><CAB5> - <20><>ʼ<EFBFBD>϶<EFBFBD>
|
|||
|
|
public void OnBeginDrag(PointerEventData eventData)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (requireExactClick)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ڵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RectTransform<72><6D>
|
|||
|
|
if (IsPointerOverGameObject(eventData))
|
|||
|
|
{
|
|||
|
|
OnDragStart(eventData.position);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>ӿ<EFBFBD>ʼ<EFBFBD><CABC>ק
|
|||
|
|
OnDragStart(eventData.position);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// IDragHandler<65>ӿ<EFBFBD>ʵ<EFBFBD><CAB5> - <20>϶<EFBFBD><CFB6><EFBFBD>
|
|||
|
|
public void OnDrag(PointerEventData eventData)
|
|||
|
|
{
|
|||
|
|
if (!dragValid) return;
|
|||
|
|
|
|||
|
|
HandleDragging(eventData.position);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// IEndDragHandler<65>ӿ<EFBFBD>ʵ<EFBFBD><CAB5> - <20><><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD>
|
|||
|
|
public void OnEndDrag(PointerEventData eventData)
|
|||
|
|
{
|
|||
|
|
if (!dragValid) return;
|
|||
|
|
|
|||
|
|
OnDragEnd();
|
|||
|
|
dragValid = false; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ק<EFBFBD><D7A7>Ч<EFBFBD><D0A7>
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>Ƿ<EFBFBD><C7B7>ڵ<EFBFBD>ǰGameObject<63><74>
|
|||
|
|
private bool IsPointerOverGameObject(PointerEventData eventData)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
var results = new List<RaycastResult>();
|
|||
|
|
|
|||
|
|
// ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DFBC><EFBFBD>
|
|||
|
|
EventSystem.current.RaycastAll(eventData, results);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
|||
|
|
foreach (var result in results)
|
|||
|
|
{
|
|||
|
|
if (result.gameObject == gameObject)
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ѡ<EFBFBD>ģ<EFBFBD><C4A3>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>õķ<C3B5><C4B7><EFBFBD>
|
|||
|
|
public void CheckPointerClick(Vector2 screenPosition)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ڵ<EFBFBD>ǰUI<55><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (IsPointInRectTransform(screenPosition))
|
|||
|
|
{
|
|||
|
|
OnDragStart(screenPosition);
|
|||
|
|
dragValid = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
dragValid = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>RectTransform<72><6D>
|
|||
|
|
private bool IsPointInRectTransform(Vector2 screenPosition)
|
|||
|
|
{
|
|||
|
|
if (dragArea == null) return false;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
RectTransform rectTransform = dragArea.rectTransform;
|
|||
|
|
Vector2 localPoint;
|
|||
|
|
RectTransformUtility.ScreenPointToLocalPointInRectangle(
|
|||
|
|
rectTransform,
|
|||
|
|
screenPosition,
|
|||
|
|
null,
|
|||
|
|
out localPoint);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ھ<EFBFBD><DABE><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
return rectTransform.rect.Contains(localPoint);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ѡ<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>תҳ<D7AA><D2B3>
|
|||
|
|
public void OnPageClick(int pageIndex)
|
|||
|
|
{
|
|||
|
|
if (currentState == SlideState.Idle)
|
|||
|
|
{
|
|||
|
|
GoToPage(pageIndex, false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void OnDragStart(Vector2 dragPosition)
|
|||
|
|
{
|
|||
|
|
dragValid = true;
|
|||
|
|
isDragging = true;
|
|||
|
|
currentState = SlideState.Dragging;
|
|||
|
|
dragStartPosition = dragPosition;
|
|||
|
|
lastDragPosition = dragPosition; // <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD>λ<EFBFBD><CEBB>
|
|||
|
|
|
|||
|
|
// <20><>¼<EFBFBD><C2BC>һ<EFBFBD><D2BB>ҳ<EFBFBD><D2B3><EFBFBD>ij<EFBFBD>ʼλ<CABC><CEBB>
|
|||
|
|
if (pages[0] != null)
|
|||
|
|
{
|
|||
|
|
pageDownPosition = pages[0].localPosition;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
totalDragDistance = 0f;
|
|||
|
|
dragSpeed = 0f;
|
|||
|
|
dragDirection = 0f;
|
|||
|
|
|
|||
|
|
if (currentPageIndex == 0)
|
|||
|
|
{
|
|||
|
|
animLast = null;
|
|||
|
|
animNext = pageAnimator[currentPageIndex + 1];
|
|||
|
|
}
|
|||
|
|
else if (currentPageIndex == pages.Length - 1)
|
|||
|
|
{
|
|||
|
|
animLast = pageAnimator[currentPageIndex - 1];
|
|||
|
|
animNext = null;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
animLast = pageAnimator[currentPageIndex - 1];
|
|||
|
|
animNext = pageAnimator[currentPageIndex + 1];
|
|||
|
|
}
|
|||
|
|
animDown = pageAnimator[currentPageIndex];
|
|||
|
|
recordPage = currentPageIndex;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>
|
|||
|
|
isAnimationsComplete = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void HandleDragging(Vector2 currentDragPosition)
|
|||
|
|
{
|
|||
|
|
if (currentState != SlideState.Dragging) return;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD>λ<EFBFBD><CEBB>
|
|||
|
|
Vector3 dragDelta = currentDragPosition - (Vector2)dragStartPosition;
|
|||
|
|
dragDelta.y = 0;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>㻬<EFBFBD><E3BBAC><EFBFBD>ٶȣ<D9B6>ÿ֡<C3BF>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE>룩
|
|||
|
|
float deltaX = currentDragPosition.x - lastDragPosition.x;
|
|||
|
|
dragSpeed = Mathf.Abs(deltaX) / Time.deltaTime;
|
|||
|
|
dragDirection = Mathf.Sign(deltaX);
|
|||
|
|
lastDragPosition = currentDragPosition;
|
|||
|
|
|
|||
|
|
// ֱ<><D6B1><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>һ<EFBFBD><D2BB>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|||
|
|
if (pages[0] != null)
|
|||
|
|
{
|
|||
|
|
Vector3 newPos = (Vector3)pageDownPosition + dragDelta;
|
|||
|
|
pages[0].localPosition = newPos;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ͬ<><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|||
|
|
for (int i = 1; i < pages.Length; i++)
|
|||
|
|
{
|
|||
|
|
if (pages[i] == null) continue;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ҳ<EFBFBD>汣<EFBFBD><E6B1A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|||
|
|
Vector3 originalRelativePos = new Vector3(i * pageSpacing, 0, 0);
|
|||
|
|
Vector3 newPos = pages[0].localPosition + originalRelativePos;
|
|||
|
|
pages[i].localPosition = newPos;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
totalDragDistance = dragDelta.x;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>Ʊ߽<C6B1>
|
|||
|
|
float minX = -(pages.Length - 1) * pageSpacing;
|
|||
|
|
float maxX = 0f;
|
|||
|
|
|
|||
|
|
Vector3 clampedPos = pages[0].localPosition;
|
|||
|
|
clampedPos.x = Mathf.Clamp(clampedPos.x, minX, maxX);
|
|||
|
|
|
|||
|
|
if (pages[0] != null)
|
|||
|
|
{
|
|||
|
|
pages[0].localPosition = clampedPos;
|
|||
|
|
|
|||
|
|
// ͬ<><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>
|
|||
|
|
for (int i = 1; i < pages.Length; i++)
|
|||
|
|
{
|
|||
|
|
if (pages[i] == null) continue;
|
|||
|
|
Vector3 pos = clampedPos + new Vector3(i * pageSpacing, 0, 0);
|
|||
|
|
pages[i].localPosition = pos;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (deltaX > 0)
|
|||
|
|
{
|
|||
|
|
disAnimMove = EnumDistance.Right;
|
|||
|
|
}
|
|||
|
|
else if (deltaX < 0)
|
|||
|
|
{
|
|||
|
|
disAnimMove = EnumDistance.Left;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (animDown != null)
|
|||
|
|
{
|
|||
|
|
animTimeDown = dragDelta.x / pageSpacing;
|
|||
|
|
StopAtTime(animDown, "open", 1 - Mathf.Abs(animTimeDown));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (dragDelta.x >= 0)
|
|||
|
|
{
|
|||
|
|
if (animLast != null)
|
|||
|
|
{
|
|||
|
|
animTimeLast = dragDelta.x / pageSpacing;
|
|||
|
|
StopAtTime(animLast, "open", Mathf.Abs(animTimeLast));
|
|||
|
|
}
|
|||
|
|
animTimeNext = dragDelta.x / pageSpacing;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (animNext != null)
|
|||
|
|
{
|
|||
|
|
animTimeNext = dragDelta.x / pageSpacing;
|
|||
|
|
StopAtTime(animNext, "open", Mathf.Abs(animTimeNext));
|
|||
|
|
}
|
|||
|
|
animTimeLast = dragDelta.x / pageSpacing;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void StopAtTime(Animator anim, string stateName, float targetTime)
|
|||
|
|
{
|
|||
|
|
// <20>Ȳ<EFBFBD><C8B2>ŵ<EFBFBD>Ŀ<EFBFBD><C4BF>ʱ<EFBFBD><CAB1>
|
|||
|
|
anim.Play(stateName, 0, targetTime);
|
|||
|
|
|
|||
|
|
// Ȼ<><EFBFBD><F3BDABB6><EFBFBD><EFBFBD>ٶ<EFBFBD><D9B6><EFBFBD>Ϊ0
|
|||
|
|
anim.speed = 0f;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void OnDragEnd()
|
|||
|
|
{
|
|||
|
|
if (!dragValid) return;
|
|||
|
|
|
|||
|
|
isDragging = false;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>㵱ǰҳ<C7B0><D2B3>λ<EFBFBD><CEBB>
|
|||
|
|
float currentX = pages[0] != null ? pages[0].localPosition.x : 0f;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD>
|
|||
|
|
float dragPercent = Mathf.Abs(totalDragDistance) / pageSpacing;
|
|||
|
|
|
|||
|
|
int targetIndex = currentPageIndex; // <20><>ʼ<EFBFBD><CABC>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ǰҳ
|
|||
|
|
|
|||
|
|
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>ǿ<EFBFBD><C7BF>ٻ<EFBFBD><D9BB><EFBFBD>
|
|||
|
|
bool isQuickSwipe = dragSpeed > 500f; // <20><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD><D9B6><EFBFBD>ֵ<EFBFBD><D6B5>500<30><30><EFBFBD><EFBFBD>/<2F><>
|
|||
|
|
|
|||
|
|
if (dragPercent > snapThreshold)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>һҳ<D2BB><D2B3><EFBFBD><EFBFBD>һҳ
|
|||
|
|
if (totalDragDistance < 0) // <20><><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD>
|
|||
|
|
{
|
|||
|
|
targetIndex = Mathf.Min(currentPageIndex + 1, pages.Length - 1);
|
|||
|
|
}
|
|||
|
|
else // <20><><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD>
|
|||
|
|
{
|
|||
|
|
targetIndex = Mathf.Max(currentPageIndex - 1, 0);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (isQuickSwipe)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶȷ<D9B6><C8B7><EFBFBD><EFBFBD>л<EFBFBD>ҳ<EFBFBD><D2B3>
|
|||
|
|
if (dragDirection < 0) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD>
|
|||
|
|
{
|
|||
|
|
targetIndex = Mathf.Min(currentPageIndex + 1, pages.Length - 1);
|
|||
|
|
}
|
|||
|
|
else if (dragDirection > 0) // <20><><EFBFBD>ҿ<EFBFBD><D2BF>ٻ<EFBFBD><D9BB><EFBFBD>
|
|||
|
|
{
|
|||
|
|
targetIndex = Mathf.Max(currentPageIndex - 1, 0);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// δ<><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>Ҳ<EFBFBD><D2B2>ǿ<EFBFBD><C7BF>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>
|
|||
|
|
float normalizedOffset = -currentX / pageSpacing;
|
|||
|
|
targetIndex = Mathf.RoundToInt(normalizedOffset);
|
|||
|
|
targetIndex = Mathf.Clamp(targetIndex, 0, pages.Length - 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD>л<EFBFBD>ҳ<EFBFBD><D2B3>
|
|||
|
|
bool isSwitchingPage = targetIndex != currentPageIndex;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (isQuickSwipe)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD>ʱʹ<CAB1><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2B4A6>
|
|||
|
|
HandleQuickSwipeAnimation(targetIndex, isSwitchingPage);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>ʱʹ<CAB1><CAB9>ԭʼ<D4AD><EFBFBD>
|
|||
|
|
HandleNormalAnimation(targetIndex, isSwitchingPage);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>л<EFBFBD>ҳ<EFBFBD><D2B3>
|
|||
|
|
if (targetIndex != currentPageIndex)
|
|||
|
|
{
|
|||
|
|
GoToPage(targetIndex, false);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>ҳ<EFBFBD><D2B3><EFBFBD>뵱ǰҳ<C7B0><D2B3><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰҳ
|
|||
|
|
currentState = SlideState.Snapping;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
disAnimMove = EnumDistance.None;
|
|||
|
|
dragValid = false; // <20><>ק<EFBFBD><D7A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶȵĶ<C8B5><C4B6><EFBFBD>
|
|||
|
|
private void HandleNormalAnimation(int targetIndex, bool isSwitchingPage)
|
|||
|
|
{
|
|||
|
|
if (disAnimMove == EnumDistance.Left)
|
|||
|
|
{
|
|||
|
|
if (animDown != null)
|
|||
|
|
{
|
|||
|
|
if (isSwitchingPage)
|
|||
|
|
{
|
|||
|
|
// <20>л<EFBFBD>ҳ<EFBFBD>棺<EFBFBD><E6A3BA>ǰҳ<C7B0><D2B3><EFBFBD><EFBFBD>close<73><65><EFBFBD><EFBFBD>
|
|||
|
|
animDown.Play("close", -1, Mathf.Abs(animTimeDown));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>л<EFBFBD>ҳ<EFBFBD>棺<EFBFBD><E6A3BA>ǰҳ<C7B0>ص<EFBFBD>open״̬
|
|||
|
|
animDown.Play("open", -1, 1 - Mathf.Abs(animTimeDown));
|
|||
|
|
}
|
|||
|
|
animDown.speed = 1;
|
|||
|
|
}
|
|||
|
|
if (animLast != null)
|
|||
|
|
{
|
|||
|
|
if (animTimeLast > 0)
|
|||
|
|
{
|
|||
|
|
if (isSwitchingPage && targetIndex == recordPage - 1)
|
|||
|
|
{
|
|||
|
|
// <20>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>һҳ<D2BB><D2B3><EFBFBD><EFBFBD>һҳ<D2BB><D2B3><EFBFBD><EFBFBD>open<65><6E><EFBFBD><EFBFBD>
|
|||
|
|
animLast.Play("open", -1, Mathf.Abs(animTimeLast));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>һҳ<D2BB><D2B3><EFBFBD><EFBFBD>һҳ<D2BB><D2B3><EFBFBD><EFBFBD>close<73><65><EFBFBD><EFBFBD>
|
|||
|
|
animLast.Play("close", -1, 1 - Mathf.Abs(animTimeLast));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
animLast.Play("close", -1, 1);
|
|||
|
|
}
|
|||
|
|
animLast.speed = 1;
|
|||
|
|
}
|
|||
|
|
if (animNext != null)
|
|||
|
|
{
|
|||
|
|
if (animTimeNext < 0)
|
|||
|
|
{
|
|||
|
|
if (isSwitchingPage && targetIndex == recordPage + 1)
|
|||
|
|
{
|
|||
|
|
// <20>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>һҳ<D2BB><D2B3><EFBFBD><EFBFBD>һҳ<D2BB><D2B3><EFBFBD><EFBFBD>open<65><6E><EFBFBD><EFBFBD>
|
|||
|
|
animNext.Play("open", -1, Mathf.Abs(animTimeNext));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>һҳ<D2BB><D2B3><EFBFBD><EFBFBD>һҳ<D2BB><D2B3><EFBFBD><EFBFBD>close<73><65><EFBFBD><EFBFBD>
|
|||
|
|
animNext.Play("close", -1, 1 - Mathf.Abs(animTimeNext));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
animNext.Play("close", -1, 1);
|
|||
|
|
}
|
|||
|
|
animNext.speed = 1;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (disAnimMove == EnumDistance.Right)
|
|||
|
|
{
|
|||
|
|
if (animDown != null)
|
|||
|
|
{
|
|||
|
|
if (isSwitchingPage)
|
|||
|
|
{
|
|||
|
|
// <20>л<EFBFBD>ҳ<EFBFBD>棺<EFBFBD><E6A3BA>ǰҳ<C7B0><D2B3><EFBFBD><EFBFBD>close<73><65><EFBFBD><EFBFBD>
|
|||
|
|
animDown.Play("close", -1, Mathf.Abs(animTimeDown));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>л<EFBFBD>ҳ<EFBFBD>棺<EFBFBD><E6A3BA>ǰҳ<C7B0>ص<EFBFBD>open״̬
|
|||
|
|
animDown.Play("open", -1, 1 - Mathf.Abs(animTimeDown));
|
|||
|
|
}
|
|||
|
|
animDown.speed = 1;
|
|||
|
|
}
|
|||
|
|
if (animLast != null)
|
|||
|
|
{
|
|||
|
|
if (animTimeLast > 0)
|
|||
|
|
{
|
|||
|
|
if (isSwitchingPage && targetIndex == recordPage - 1)
|
|||
|
|
{
|
|||
|
|
// <20>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>һҳ<D2BB><D2B3><EFBFBD><EFBFBD>һҳ<D2BB><D2B3><EFBFBD><EFBFBD>open<65><6E><EFBFBD><EFBFBD>
|
|||
|
|
animLast.Play("open", -1, Mathf.Abs(animTimeLast));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>һҳ<D2BB><D2B3><EFBFBD><EFBFBD>һҳ<D2BB><D2B3><EFBFBD><EFBFBD>close<73><65><EFBFBD><EFBFBD>
|
|||
|
|
animLast.Play("close", -1, 1 - Mathf.Abs(animTimeLast));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
animLast.Play("close", -1, 1);
|
|||
|
|
}
|
|||
|
|
animLast.speed = 1;
|
|||
|
|
}
|
|||
|
|
if (animNext != null)
|
|||
|
|
{
|
|||
|
|
if (animTimeNext < 0)
|
|||
|
|
{
|
|||
|
|
if (isSwitchingPage && targetIndex == recordPage + 1)
|
|||
|
|
{
|
|||
|
|
// <20>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>һҳ<D2BB><D2B3><EFBFBD><EFBFBD>һҳ<D2BB><D2B3><EFBFBD><EFBFBD>open<65><6E><EFBFBD><EFBFBD>
|
|||
|
|
animNext.Play("open", -1, Mathf.Abs(animTimeNext));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>һҳ<D2BB><D2B3><EFBFBD><EFBFBD>һҳ<D2BB><D2B3><EFBFBD><EFBFBD>close<73><65><EFBFBD><EFBFBD>
|
|||
|
|
animNext.Play("close", -1, 1 - Mathf.Abs(animTimeNext));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
animNext.speed = 1;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭʼ<D4AD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (animDown != null)
|
|||
|
|
{
|
|||
|
|
if (isSwitchingPage)
|
|||
|
|
{
|
|||
|
|
// <20>л<EFBFBD>ҳ<EFBFBD>棺<EFBFBD><E6A3BA>ǰҳ<C7B0><D2B3><EFBFBD><EFBFBD>close<73><65><EFBFBD><EFBFBD>
|
|||
|
|
animDown.Play("close", -1, Mathf.Abs(animTimeDown));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>л<EFBFBD>ҳ<EFBFBD>棺<EFBFBD><E6A3BA>ǰҳ<C7B0>ص<EFBFBD>open״̬
|
|||
|
|
animDown.Play("open", -1, 1 - Mathf.Abs(animTimeDown));
|
|||
|
|
}
|
|||
|
|
animDown.speed = 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (isSwitchingPage)
|
|||
|
|
{
|
|||
|
|
// Ŀ<><C4BF>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD>open<65><6E><EFBFBD><EFBFBD>
|
|||
|
|
if (pageAnimator[targetIndex] != null)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㿪ʼʱ<CABC><CAB1>
|
|||
|
|
float startTime = 0f;
|
|||
|
|
if (targetIndex < recordPage && animLast != null)
|
|||
|
|
{
|
|||
|
|
startTime = Mathf.Abs(animTimeLast);
|
|||
|
|
}
|
|||
|
|
else if (targetIndex > recordPage && animNext != null)
|
|||
|
|
{
|
|||
|
|
startTime = Mathf.Abs(animTimeNext);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
startTime = Mathf.Clamp01(startTime);
|
|||
|
|
pageAnimator[targetIndex].Play("open", -1, startTime);
|
|||
|
|
pageAnimator[targetIndex].speed = 1;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ǻҳ<EEB6AF><D2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊclose״̬
|
|||
|
|
for (int i = 0; i < pageAnimator.Length; i++)
|
|||
|
|
{
|
|||
|
|
if (pageAnimator[i] == null) continue;
|
|||
|
|
if (i == recordPage || i == targetIndex) continue;
|
|||
|
|
|
|||
|
|
pageAnimator[i].Play("close", -1, 1);
|
|||
|
|
pageAnimator[i].speed = 0; // <20><><EFBFBD><EFBFBD><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD>
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
|||
|
|
private void HandleQuickSwipeAnimation(int targetIndex, bool isSwitchingPage)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (isSwitchingPage)
|
|||
|
|
{
|
|||
|
|
// <20><>ǰҳ<C7B0><D2B3><EFBFBD><EFBFBD>close<73><65><EFBFBD><EFBFBD>
|
|||
|
|
if (animDown != null)
|
|||
|
|
{
|
|||
|
|
float startTime = Mathf.Abs(animTimeDown);
|
|||
|
|
startTime = Mathf.Clamp01(startTime);
|
|||
|
|
animDown.Play("close", -1, startTime);
|
|||
|
|
animDown.speed = 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Ŀ<><C4BF>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD>open<65><6E><EFBFBD><EFBFBD>
|
|||
|
|
if (pageAnimator[targetIndex] != null)
|
|||
|
|
{
|
|||
|
|
float startTime = 0f;
|
|||
|
|
if (targetIndex < recordPage && animLast != null)
|
|||
|
|
{
|
|||
|
|
startTime = Mathf.Abs(animTimeLast);
|
|||
|
|
}
|
|||
|
|
else if (targetIndex > recordPage && animNext != null)
|
|||
|
|
{
|
|||
|
|
startTime = Mathf.Abs(animTimeNext);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
startTime = Mathf.Clamp01(startTime);
|
|||
|
|
pageAnimator[targetIndex].Play("open", -1, startTime);
|
|||
|
|
pageAnimator[targetIndex].speed = 1;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>л<EFBFBD>ҳ<EFBFBD>棬<EFBFBD>ص<EFBFBD>ԭʼ״̬
|
|||
|
|
if (animDown != null)
|
|||
|
|
{
|
|||
|
|
animDown.Play("open", -1, 1 - Mathf.Abs(animTimeDown));
|
|||
|
|
animDown.speed = 1;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ȷ<><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>ȷ״̬
|
|||
|
|
ResetAllAnimations(targetIndex, isSwitchingPage);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD>״̬
|
|||
|
|
private void ResetAllAnimations(int targetIndex, bool isSwitchingPage)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>close״̬
|
|||
|
|
for (int i = 0; i < pageAnimator.Length; i++)
|
|||
|
|
{
|
|||
|
|
if (pageAnimator[i] == null) continue;
|
|||
|
|
|
|||
|
|
if (isSwitchingPage)
|
|||
|
|
{
|
|||
|
|
if (i == recordPage || i == targetIndex) continue;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (i == recordPage) continue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ֱ<><D6B1><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>close״̬<D7B4>Ľ<EFBFBD><C4BD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
|
|||
|
|
pageAnimator[i].Play("close", -1, 1);
|
|||
|
|
pageAnimator[i].speed = 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>鶯<EFBFBD><E9B6AF><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
private void CheckAnimationsComplete()
|
|||
|
|
{
|
|||
|
|
if (isAnimationsComplete) return;
|
|||
|
|
|
|||
|
|
bool allComplete = true;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>鵱ǰҳ<C7B0><D2B3><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>״̬
|
|||
|
|
if (animDown != null && animDown.speed > 0)
|
|||
|
|
{
|
|||
|
|
AnimatorStateInfo stateInfo = animDown.GetCurrentAnimatorStateInfo(0);
|
|||
|
|
if (!stateInfo.IsName("close") && !stateInfo.IsName("open"))
|
|||
|
|
{
|
|||
|
|
allComplete = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (allComplete)
|
|||
|
|
{
|
|||
|
|
isAnimationsComplete = true;
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD>涼<EFBFBD><E6B6BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>״̬
|
|||
|
|
EnsureFinalAnimationStates();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ȷ<><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC>ȷ
|
|||
|
|
private void EnsureFinalAnimationStates()
|
|||
|
|
{
|
|||
|
|
// <20><>ǰҳ<C7B0><D2B3>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>open״̬
|
|||
|
|
if (pageAnimator[currentPageIndex] != null)
|
|||
|
|
{
|
|||
|
|
pageAnimator[currentPageIndex].Play("open", -1, 1);
|
|||
|
|
pageAnimator[currentPageIndex].speed = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>close״̬
|
|||
|
|
for (int i = 0; i < pageAnimator.Length; i++)
|
|||
|
|
{
|
|||
|
|
if (i == currentPageIndex || pageAnimator[i] == null) continue;
|
|||
|
|
pageAnimator[i].Play("close", -1, 1);
|
|||
|
|
pageAnimator[i].speed = 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void SmoothToTarget()
|
|||
|
|
{
|
|||
|
|
if (pages[0] == null) return;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>㵱ǰ<E3B5B1><C7B0>һ<EFBFBD><D2BB>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>λ<EFBFBD><CEBB>
|
|||
|
|
float targetX = -currentPageIndex * pageSpacing;
|
|||
|
|
float currentX = pages[0].localPosition.x;
|
|||
|
|
|
|||
|
|
// ƽ<><C6BD><EFBFBD>ƶ<EFBFBD>
|
|||
|
|
float t = Time.deltaTime * snapSpeed;
|
|||
|
|
float newX = Mathf.Lerp(currentX, targetX, t);
|
|||
|
|
|
|||
|
|
// Ӧ<><D3A6><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|||
|
|
Vector3 newPos = pages[0].localPosition;
|
|||
|
|
newPos.x = newX;
|
|||
|
|
pages[0].localPosition = newPos;
|
|||
|
|
|
|||
|
|
// ͬ<><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>
|
|||
|
|
for (int i = 1; i < pages.Length; i++)
|
|||
|
|
{
|
|||
|
|
if (pages[i] == null) continue;
|
|||
|
|
Vector3 pos = newPos + new Vector3(i * pageSpacing, 0, 0);
|
|||
|
|
pages[i].localPosition = pos;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<C7B7>Ŀ<EFBFBD><C4BF>
|
|||
|
|
if (Mathf.Abs(newX - targetX) < 0.5f)
|
|||
|
|
{
|
|||
|
|
// ֱ<><D6B1><EFBFBD><EFBFBD><EFBFBD>þ<EFBFBD>ȷλ<C8B7><CEBB>
|
|||
|
|
newPos.x = targetX;
|
|||
|
|
pages[0].localPosition = newPos;
|
|||
|
|
|
|||
|
|
for (int i = 1; i < pages.Length; i++)
|
|||
|
|
{
|
|||
|
|
if (pages[i] == null) continue;
|
|||
|
|
Vector3 pos = newPos + new Vector3(i * pageSpacing, 0, 0);
|
|||
|
|
pages[i].localPosition = pos;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
currentState = SlideState.Idle;
|
|||
|
|
|
|||
|
|
// λ<>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC>ȷ
|
|||
|
|
EnsureFinalAnimationStates();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void UpdateCurrentPageIndex()
|
|||
|
|
{
|
|||
|
|
if (pages[0] == null) return;
|
|||
|
|
|
|||
|
|
float currentX = pages[0].localPosition.x;
|
|||
|
|
float normalizedOffset = -currentX / pageSpacing + 0.5f;
|
|||
|
|
int newIndex = Mathf.FloorToInt(normalizedOffset);
|
|||
|
|
newIndex = Mathf.Clamp(newIndex, 0, pages.Length - 1);
|
|||
|
|
|
|||
|
|
if (newIndex != currentPageIndex)
|
|||
|
|
{
|
|||
|
|
currentPageIndex = newIndex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void GoToPage(int targetIndex, bool directJump = false)
|
|||
|
|
{
|
|||
|
|
if (targetIndex < 0 || targetIndex >= pages.Length) return;
|
|||
|
|
|
|||
|
|
if (directJump)
|
|||
|
|
{
|
|||
|
|
// ʹ<><CAB9>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>ת
|
|||
|
|
JumpToPage(targetIndex);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// ʹ<><CAB9>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD>
|
|||
|
|
currentPageIndex = targetIndex;
|
|||
|
|
|
|||
|
|
if (currentState != SlideState.Dragging)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|||
|
|
float targetX = -currentPageIndex * pageSpacing;
|
|||
|
|
|
|||
|
|
for (int i = 0; i < pages.Length; i++)
|
|||
|
|
{
|
|||
|
|
if (pages[i] == null) continue;
|
|||
|
|
float xPos = targetX + i * pageSpacing;
|
|||
|
|
pages[i].localPosition = new Vector3(xPos, 0, 0);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
currentState = SlideState.Idle;
|
|||
|
|
|
|||
|
|
// ҳ<><D2B3><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC>ȷ
|
|||
|
|
EnsureFinalAnimationStates();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
|||
|
|
currentState = SlideState.Snapping;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void NextPage()
|
|||
|
|
{
|
|||
|
|
int nextIndex = Mathf.Min(currentPageIndex + 1, pages.Length - 1);
|
|||
|
|
if (nextIndex != currentPageIndex)
|
|||
|
|
{
|
|||
|
|
GoToPage(nextIndex, false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void PreviousPage()
|
|||
|
|
{
|
|||
|
|
int prevIndex = Mathf.Max(currentPageIndex - 1, 0);
|
|||
|
|
if (prevIndex != currentPageIndex)
|
|||
|
|
{
|
|||
|
|
GoToPage(prevIndex, false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void JumpToPage(int targetIndex)
|
|||
|
|
{
|
|||
|
|
if (targetIndex < 0 || targetIndex >= pages.Length) return;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD>Ŀ<EFBFBD><C4BF>ҳ<EFBFBD>棬ֱ<E6A3AC>ӷ<EFBFBD><D3B7><EFBFBD>
|
|||
|
|
if (targetIndex == currentPageIndex) return;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6>У<EFBFBD><D0A3><EFBFBD>ֹͣ<CDA3>϶<EFBFBD>
|
|||
|
|
if (currentState == SlideState.Dragging)
|
|||
|
|
{
|
|||
|
|
currentState = SlideState.Idle;
|
|||
|
|
isDragging = false;
|
|||
|
|
dragValid = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>
|
|||
|
|
jumpTargetIndex = targetIndex;
|
|||
|
|
currentJumpMode = JumpMode.Direct;
|
|||
|
|
jumpProgress = 0f;
|
|||
|
|
|
|||
|
|
// <20>ؼ<EFBFBD><D8BC><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>ʼλ<CABC>ú<EFBFBD>Ŀ<EFBFBD><C4BF>λ<EFBFBD><CEBB>
|
|||
|
|
jumpStartX = pages[0].localPosition.x;
|
|||
|
|
jumpTargetX = -targetIndex * pageSpacing;
|
|||
|
|
|
|||
|
|
// <20><>¼<EFBFBD><C2BC>תǰ<D7AA><C7B0>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
int previousPageIndex = currentPageIndex;
|
|||
|
|
|
|||
|
|
// ֱ<>Ӹ<EFBFBD><D3B8>µ<EFBFBD>ǰҳ<C7B0><D2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
currentPageIndex = targetIndex;
|
|||
|
|
|
|||
|
|
// ֹͣ<CDA3><D6B9><EFBFBD>е<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
|||
|
|
StopAllAnimations();
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
HandleDirectJumpAnimation(previousPageIndex, targetIndex);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>
|
|||
|
|
private void StopAllAnimations()
|
|||
|
|
{
|
|||
|
|
for (int i = 0; i < pageAnimator.Length; i++)
|
|||
|
|
{
|
|||
|
|
if (pageAnimator[i] != null)
|
|||
|
|
{
|
|||
|
|
pageAnimator[i].speed = 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>ת<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
|||
|
|
private void HandleDirectJumpAnimation(int fromIndex, int toIndex)
|
|||
|
|
{
|
|||
|
|
// <20>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
|||
|
|
for (int i = 0; i < pageAnimator.Length; i++)
|
|||
|
|
{
|
|||
|
|
if (pageAnimator[i] == null) continue;
|
|||
|
|
|
|||
|
|
if (i == toIndex)
|
|||
|
|
{
|
|||
|
|
// Ŀ<><C4BF>ҳ<EFBFBD><D2B3>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊopen״̬
|
|||
|
|
pageAnimator[i].Play("open", -1, 1);
|
|||
|
|
}
|
|||
|
|
else if (i == fromIndex)
|
|||
|
|
{
|
|||
|
|
// Դҳ<D4B4><D2B3>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊclose״̬
|
|||
|
|
pageAnimator[i].Play("close", -1, 1);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ҳ<EFBFBD>汣<EFBFBD><E6B1A3>ԭ<EFBFBD><D4AD>״̬<D7B4><CCAC>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>close״̬<D7B4><CCAC>
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD><C7B2>ı<EFBFBD><C4B1><EFBFBD><EFBFBD>ǵ<EFBFBD>״̬<D7B4><CCAC>ֻ<EFBFBD><D6BB>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD><C7B2><EFBFBD><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD>
|
|||
|
|
if (pageAnimator[i].GetCurrentAnimatorStateInfo(0).IsName("open"))
|
|||
|
|
{
|
|||
|
|
pageAnimator[i].Play("close", -1, 1);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
pageAnimator[i].speed = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><E2B6AF><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD>д<EFBFBD><D0B4><EFBFBD>
|
|||
|
|
if (pageTitle != null && pageTitle.Length > 0)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD><D3B1><EFBFBD><E2B6AF><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
// <20><><EFBFBD>磺<EFBFBD><E7A3BA><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>ҳ<EFBFBD><D2B3><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
enum EnumDistance
|
|||
|
|
{
|
|||
|
|
None,
|
|||
|
|
Left,
|
|||
|
|
Right
|
|||
|
|
}
|
|||
|
|
}
|