Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
730 B

  1. public IEnumerator FlipToPage(int targetPage, float animationTime){
  2. int startPage = currentPage;
  3. float elapsedTime = 0;
  4. while (elapsedTime < animationTime){
  5. currentPage = (int)Mathf.lerp(startPage,targetPage,elaspedTime/animationTime);
  6. yield return new waitForFrame();
  7. elapsedTime += Time.deltaTime;
  8. }
  9. currentPage = targetPage;
  10. }
  11. public IEnumerator PingPong(int startPage, int endPage, float animationTime,float PauseTime){
  12. int currentPage = currentPage;
  13. int targetPage = endPage;
  14. While(true){
  15. yield return startCoroutine(FlipToPage(targetPage,animationTime)
  16. yield return new WaitForSeconds(PauseTime)
  17. targetPage = (targetPage == endPage) ? startPage : endPage
  18. }
  19. }