Wes xx build fix

This commit is contained in:
Dries Van Schuylenbergh
2023-03-09 12:44:11 +00:00
committed by Louis Adriaens
parent 601cf38c61
commit 2fa54620ef
74 changed files with 1009 additions and 214 deletions

View File

@@ -1,10 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
using UnityEngine.UI;
using TMPro;
using UnityEditor;
public class StartPause : MonoBehaviour
{
@@ -37,8 +34,8 @@ public class StartPause : MonoBehaviour
// Index of the current word/letter in the course.learnables list
private int currentWordIndex = 0;
// In my example, i have 4 videos/images
private int maxWords = 4;
// This holds the amount of words in the course
private int maxWords;
// Number of correct words so far
// (can be modified to a list or something like that to give better feedback)
private int correctWords = 0;
@@ -47,9 +44,9 @@ public class StartPause : MonoBehaviour
{
// Setting up course
course = courselist.courses[courselist.currentCourseIndex];
maxWords = course.learnables.Count;
// Create entry in current user for keeping track of progress
user = userList.users[userList.currentUserIndex];
user = userList.GetCurrentUser();
progress = user.courses.Find((p) => p != null && p.Get<CourseIndex>("courseIndex") == course.index);
if (progress == null)
{
@@ -58,7 +55,7 @@ public class StartPause : MonoBehaviour
progress.AddOrUpdate<float>("courseProgress", -1.0f);
user.courses.Add(progress);
}
EditorUtility.SetDirty(user);
userList.Save();
// Setup UI
button.image.sprite = pauseSprite;
@@ -73,10 +70,9 @@ public class StartPause : MonoBehaviour
player.clip = course.learnables[currentWordIndex].clip;
// This loads first frame, so that it can be used as a sort-of preview for the video
player.Play();
player.Pause();
// As the video will start paused -> show button
// As the video will start playiing -> hide button
Color col = button.image.color;
col.a = 255;
col.a = 0;
button.image.color = col;
}
@@ -116,7 +112,7 @@ public class StartPause : MonoBehaviour
// TODO: fix correct word count
correctWords++;
progress.AddOrUpdate<float>("courseProgress", (float)correctWords / (float)maxWords);
EditorUtility.SetDirty(user);
userList.Save();
// Update UI if course is not finished yet
if (currentWordIndex < maxWords)
@@ -135,5 +131,6 @@ public class StartPause : MonoBehaviour
{
// TODO: update progress (maybe this can also be at the `NextSign()`-method)
progress.AddOrUpdate<float>("courseProgress", correctWords / maxWords);
userList.Save();
}
}