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

50
Assets/Scripts/Webcam.cs Normal file
View File

@@ -0,0 +1,50 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class Webcam : MonoBehaviour
{
int camdex = 0;
WebCamTexture tex;
public RawImage display;
public Button nextSignButton;
void Awake(){
WebCamDevice device = WebCamTexture.devices[camdex];
tex = new WebCamTexture(device.name);
display.texture = tex;
tex.Play();
}
public void SwapCam(){
if(WebCamTexture.devices.Length > 0){
// Stop the old camera
display.texture = null;
tex.Stop();
tex = null;
// Find the new camera
camdex += 1;
camdex %= WebCamTexture.devices.Length;
// Start the new camera
WebCamDevice device = WebCamTexture.devices[camdex];
tex = new WebCamTexture(device.name);
display.texture = tex;
tex.Play();
}
}
// Scene changing is implemented here to avoid problems with webcam
public void loadScene(string sceneName) {
display.texture = null;
tex.Stop();
tex = null;
SceneManager.LoadScene(sceneName);
}
}