// Update is called once per frame void Update() { if (isFlipping) { elapsedTime += Time.deltaTime; if (elapsedTime < duration) { if (flipMode == FlipMode.RightToLeft) { float x = xc + (0.5f - elapsedTime / duration) * 2 * (pageWidth); float y = (-pageHeight / (pageWidth * pageWidth)) * (x - xc) * (x - xc); book.UpdateBookRTLToPoint(new Vector3(x, y, 0)); } else { float x = xc - (0.5f - elapsedTime / duration) * 2 * (pageWidth); float y = (-pageHeight / (pageWidth * pageWidth)) * (x - xc) * (x - xc); book.UpdateBookLTRToPoint(new Vector3(x, y, 0)); } } else { book.Flip(); isFlipping = false; this.enabled = false; if (finish != null) { finish(); } } } }
// Update is called once per frame void Update() { if (isFlipping) { ParticleDisabler.instance.ToggleParticles(false); elapsedTime += Time.deltaTime; if (elapsedTime < duration) { if (flipMode == FlipMode.RightToLeft) { float x = xc + (0.5f - elapsedTime / duration) * 2 * (pageWidth); float y = (-pageHeight / (pageWidth * pageWidth)) * (x - xc) * (x - xc); book.UpdateBookRTLToPoint(new Vector3(x, y, 0)); } else { float x = xc - (0.5f - elapsedTime / duration) * 2 * (pageWidth); float y = (-pageHeight / (pageWidth * pageWidth)) * (x - xc) * (x - xc); book.UpdateBookLTRToPoint(new Vector3(x, y, 0)); } } else { ParticleDisabler.instance.ToggleParticles(true); book.GoToPage(book.targetPageNumber); //book.Flip(); isFlipping = false; this.enabled = false; if (finish != null) { finish(); } } } }
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(); }