Resolve WES-143 "Feedback courses"
This commit is contained in:
committed by
Jerome Coudron
parent
c20cd89c3a
commit
c358ac59e4
86
Assets/Courses/Scripts/PanelWithVideoAndImage.cs
Normal file
86
Assets/Courses/Scripts/PanelWithVideoAndImage.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Video;
|
||||
|
||||
public class PanelWithVideoAndImage : MonoBehaviour
|
||||
{
|
||||
public GameObject feedbackProgressObject;
|
||||
public GameObject previewMessage;
|
||||
public bool isPreview;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to instructional video player
|
||||
/// </summary>
|
||||
public VideoPlayer videoPlayer;
|
||||
public Image playButton;
|
||||
public RawImage webcamScreen;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the image for displaying the current words sprite
|
||||
/// </summary>
|
||||
public Transform signImageContainer;
|
||||
|
||||
public GameObject signImagePrefab;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the feedback field
|
||||
/// </summary>
|
||||
public TMP_Text feedbackText;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the progress bar
|
||||
/// </summary>
|
||||
public Slider feedbackProgressBar;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the progress bar image, so we can add fancy colors
|
||||
/// </summary>
|
||||
public Image feedbackProgressImage;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the image for displaying the current words sprite
|
||||
/// </summary>
|
||||
public TMP_Text signName;
|
||||
|
||||
public List<Learnable> signs;
|
||||
public int currentSignIndex;
|
||||
|
||||
public void Display()
|
||||
{
|
||||
Learnable currentSign = signs[currentSignIndex];
|
||||
signName.text = currentSign.name;
|
||||
videoPlayer.aspectRatio = VideoAspectRatio.FitInside;
|
||||
videoPlayer.clip = currentSign.clip;
|
||||
videoPlayer.Play();
|
||||
|
||||
feedbackProgressObject.SetActive(!isPreview);
|
||||
previewMessage.SetActive(isPreview);
|
||||
|
||||
List<Sprite> sprites = new List<Sprite>() { currentSign.image };
|
||||
if (currentSign.handGuide != null)
|
||||
sprites.Add(currentSign.handGuide);
|
||||
|
||||
foreach (Sprite s in sprites)
|
||||
{
|
||||
GameObject sprite = GameObject.Instantiate(signImagePrefab, signImageContainer);
|
||||
sprite.GetComponent<Image>().sprite = s;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when the pause-button is pressed on the video.
|
||||
/// It switches between playing and pausing the video.
|
||||
/// It then makes the button invisible when the video is playing, or visible when it's paused.
|
||||
/// </summary>
|
||||
public void TogglePlayPause()
|
||||
{
|
||||
if (!videoPlayer.isPlaying)
|
||||
// Play video and hide button
|
||||
videoPlayer.Play();
|
||||
else
|
||||
// Pause video and show button
|
||||
videoPlayer.Pause();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user