Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IEnumerator AlignToChapter () { // Co-routine for animating the "snap" to the current chapter when the user releases
- bool aligning = true; // Create and Set all of the current values in preparation of "lerping"
- float startTime = Time.time;
- float currentLocation = navBar.Value;
- float closestChapter = increment * (Mathf.Round(navBar.Value/increment));
- while (aligning) { // While aligning: Lerp the Nav Bar Know location to the next closest chapter
- navBar.Value = Mathf.Lerp (currentLocation, closestChapter, (Time.time - startTime) * alignmentSpeed);
- if (Mathf.Abs (closestChapter - navBar.Value) < threshold) {
- navBar.Value = closestChapter;
- aligning = false;
- }
- yield return null;
- }
- guiController.GoToChapter (currentChapter); // Enable code here for triggering of new chapter AFTER the knob has settled
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement