wes-50 -> dev
This commit is contained in:
committed by
Tibe Habils
parent
33bdc1464a
commit
f5689090cd
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user