public static void FlipPage(int pageNumber, BookPro book, float duration, FlipMode mode, Action OnComplete) { book.targetPageNumber = pageNumber; HomePageFlipper flipper = book.GetComponent <HomePageFlipper>(); if (!flipper) { flipper = book.gameObject.AddComponent <HomePageFlipper>(); } flipper.enabled = true; flipper.book = book; flipper.isFlipping = true; flipper.duration = duration - Time.deltaTime; flipper.finish = OnComplete; flipper.xc = (book.EndBottomLeft.x + book.EndBottomRight.x) / 2; flipper.pageWidth = (book.EndBottomRight.x - book.EndBottomLeft.x) / 2; flipper.pageHeight = Mathf.Abs(book.EndBottomRight.y); flipper.flipMode = mode; flipper.elapsedTime = 0; float x; if (mode == FlipMode.RightToLeft) { x = flipper.xc + (flipper.pageWidth * 0.99f); float y = (-flipper.pageHeight / (flipper.pageWidth * flipper.pageWidth)) * (x - flipper.xc) * (x - flipper.xc); book.DragRightPageToPoint(new Vector3(x, y, 0)); } else { x = flipper.xc - (flipper.pageWidth * 0.99f); float y = (-flipper.pageHeight / (flipper.pageWidth * flipper.pageWidth)) * (x - flipper.xc) * (x - flipper.xc); book.DragLeftPageToPoint(new Vector3(x, y, 0)); } }
IEnumerator <float> FlipLTR(float xc, float xl, float h, float frameTime, float dx) { float x = xc - xl; float y = (-h / (xl * xl)) * (x - xc) * (x - xc); ControledBook.DragLeftPageToPoint(new Vector3(x, y, 0)); for (int i = 0; i < AnimationFramesCount; i++) { y = (-h / (xl * xl)) * (x - xc) * (x - xc); ControledBook.UpdateBookLTRToPoint(new Vector3(x, y, 0)); yield return(Timing.WaitForSeconds(frameTime)); x += dx; } ControledBook.ReleasePage(); }