private IEnumerator SetImage(PageSwitchType pageSwitchType) { if (chapterThumbnails[0] == null) { Debug.LogError("No chapter thumbnails! @SinglePlayerMenu.cs"); yield return(null); } if (chapterThumbnails[currentPage] != null) { nextThumbnail.sprite = chapterThumbnails[currentPage]; } else { currentThumbnail.sprite = nullSceneImage; nextThumbnail.sprite = nullSceneImage2; } switch (pageSwitchType) { case PageSwitchType.right: currentThumbnail.sprite = chapterThumbnails[currentPage - 1]; break; case PageSwitchType.left: currentThumbnail.sprite = chapterThumbnails[currentPage + 1]; break; } yield return(new WaitForSeconds(0.5f)); // GetCurrentAnimatorStateInfo(0).length gives 0.5f but it wont yield for that amount of time???? currentThumbnail.sprite = chapterThumbnails[currentPage]; }
public void OnSwitchPage(PageSwitchType pageSwitchType) { if (thumbnailAnimator.GetCurrentAnimatorStateInfo(0).IsName("idle")) // this is the key to fixing the gun controller { switch (pageSwitchType) { case PageSwitchType.left: currentPage--; chapterText.text = chapterTexts[currentPage]; thumbnailAnimator.Play(prevThumb); OnPageUpdate(); // this is in here so i can make the code look cooler, it wont make a difference. StartCoroutine(SetImage(pageSwitchType)); break; case PageSwitchType.right: currentPage++; chapterText.text = chapterTexts[currentPage]; thumbnailAnimator.Play(nextThumb); OnPageUpdate(); StartCoroutine(SetImage(pageSwitchType)); break; } } }