wes-50 -> dev

This commit is contained in:
Jerome Coudron
2023-03-05 15:52:00 +00:00
committed by Tibe Habils
parent 33bdc1464a
commit f5689090cd
36 changed files with 1110 additions and 156 deletions

View File

@@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
[CreateAssetMenu(fileName="New Course", menuName="course")]
public class Course : ScriptableObject
{
public string title;
public string description;
public Sprite thumbnail;
public int progress;
public Sprite[] images;
public VideoClip[] videos;
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f6b23e64e6ffb12459ed4f37d7305852
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class CourseIndex
{
// Start is called before the first frame update
public static int index = 0;
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3ac4eb825ce7bf5499f083eaf34d5d4d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName="New CourseList", menuName="CourseList")]
public class CourseList : ScriptableObject
{
public Course[] courses;
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 96fe8874f9754b545ae25fb826312ebc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,43 +1,55 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
using UnityEngine.UI;
using UnityEngine.Video; // To alter video
using UnityEngine.UI; // For general image + button jobs
using TMPro; // For text
public class StartPause : MonoBehaviour
{
public VideoPlayer player;
public Button button;
public Sprite pauseSprite;
public Image image;
public Image word_image;
public TextMeshProUGUI title;
public CourseList courselist;
private Course course;
private int word_i = 0;
// In my example, i have 4 videos/images
private int max_words = 4;
// Start is called before the first frame update
public void Start()
public void Awake()
{
next_video();
//next_image();
course = courselist.courses[CourseIndex.index];
button.image.sprite = pauseSprite;
title.text = course.name;
next_video();
next_image();
}
// These two functions generate video and image from files
private void next_video(){
player.clip = course.videos[word_i];
// 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
Color col = button.image.color;
col.a = 255;
button.image.color = col;
}
// These two functions generate video and image from files
private void next_video(){
// TODO: fix with dynamic loading
player.url = $"Assets/Courses/Videos/{word_i}.mp4";
}
// This doesn't work
private void next_image(){
// TODO: fix with dynamic loading
Sprite tex = Resources.Load($"Assets/Courses/Images/{word_i}.png") as Sprite;
image.sprite = tex;
Sprite tex = course.images[word_i];
word_image.sprite = tex;
}
// Activate by pressing the center of the screen
@@ -45,6 +57,7 @@ public class StartPause : MonoBehaviour
{
if (!player.isPlaying)
{
// Play video and hide button
player.Play();
Color col = button.image.color;
col.a = 0;
@@ -52,6 +65,7 @@ public class StartPause : MonoBehaviour
}
else
{
// Pause video and show button
player.Pause();
Color col = button.image.color;
col.a = 255;
@@ -61,11 +75,9 @@ public class StartPause : MonoBehaviour
// Press next-sign button for next word
public void NextSign(){
// Fetch next video and image from log
// Idea : do this by numbering video's and images and using increment to find them.
word_i++;
word_i %= max_words;
next_video();
//next_image();
next_image();
}
}

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using TMPro;
public class Webcam : MonoBehaviour
{
@@ -10,9 +11,13 @@ public class Webcam : MonoBehaviour
WebCamTexture tex;
public RawImage display;
public Button nextSignButton;
public Button feedback;
public GameObject popup;
public TextMeshProUGUI dynamic;
void Awake(){
popup.SetActive(false);
WebCamDevice device = WebCamTexture.devices[camdex];
tex = new WebCamTexture(device.name);
display.texture = tex;
@@ -47,4 +52,23 @@ public class Webcam : MonoBehaviour
SceneManager.LoadScene(sceneName);
}
public void Show_feedback(){
if(popup.activeSelf){
dynamic.text = "";
popup.SetActive(false);
return;
}
double index = UnityEngine.Random.value;
if(index < 0.5){
dynamic.text = "Poor";
}
else if(index > 0.8){
dynamic.text = "Excellent";
}
else{
dynamic.text = "Good";
}
popup.SetActive(true);
}
}