added course prototype, image switch not working yet

This commit is contained in:
jrcoudro
2023-02-25 10:49:12 +01:00
parent faacb4406e
commit f2aff6fcce
35 changed files with 3516 additions and 291 deletions

View File

@@ -0,0 +1,69 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
using UnityEngine.UI;
public class StartPause : MonoBehaviour
{
public VideoPlayer player;
public Button button;
public Sprite pauseSprite;
public Image image;
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()
{
next_video();
//next_image();
button.image.sprite = pauseSprite;
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(){
player.url = $"Assets/Videos/{word_i}.mp4";
}
// This doesn't work
private void next_image(){
Sprite tex = Resources.Load($"Assets/Images/{word_i}.png") as Sprite;
image.sprite = tex;
}
// Activate by pressing the center of the screen
public void Pause()
{
if (!player.isPlaying)
{
player.Play();
Color col = button.image.color;
col.a = 0;
button.image.color = col;
}
else
{
player.Pause();
Color col = button.image.color;
col.a = 255;
button.image.color = col;
}
}
// 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();
}
}