using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using System.Collections;
using System;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
#endif
namespace BookCurlPro
{
public enum FlipMode
{
RightToLeft,
LeftToRight
}
public class BookPro : MonoBehaviour
{
Canvas canvas;
[SerializeField]
RectTransform BookPanel;
public Image ClippingPlane;
public Image Shadow;
public Image LeftPageShadow;
public Image RightPageShadow;
public Image ShadowLTR;
public RectTransform LeftPageTransform;
public RectTransform RightPageTransform;
public bool interactable = true;
public bool enableShadowEffect = true;
[Tooltip("Uncheck this if the book does not contain transparent pages to improve the overall performance")]
public bool hasTransparentPages = true;
[HideInInspector]
public int currentPaper = 0;
[HideInInspector]
public Paper[] papers;
///
/// OnFlip invocation list, called when any page flipped
///
public UnityEvent OnFlip;
///
/// The Current Shown paper (the paper its front shown in right part)
///
public int CurrentPaper
{
get { return currentPaper; }
set
{
if (value != currentPaper)
{
if (value < StartFlippingPaper)
currentPaper = StartFlippingPaper;
else if (value > EndFlippingPaper + 1)
currentPaper = EndFlippingPaper + 1;
else
currentPaper = value;
UpdatePages();
}
}
}
[HideInInspector]
public int StartFlippingPaper = 0;
[HideInInspector]
public int EndFlippingPaper = 1;
public Vector3 EndBottomLeft
{
get { return ebl; }
}
public Vector3 EndBottomRight
{
get { return ebr; }
}
public float Height
{
get
{
return BookPanel.rect.height;
}
}
Image Left;
Image Right;
//current flip mode
FlipMode mode;
///
/// this value should e true while the user darg the page
///
bool pageDragging = false;
///
/// should be true when the page tween forward or backward after release
///
bool tweening = false;
// Use this for initialization
void Start()
{
Canvas[] c = GetComponentsInParent