Files
unity-application/Assets/Hangman/Scripts/HangManWebcam.cs
2023-03-19 23:02:50 +00:00

63 lines
1.5 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class HangManWebcam : WebCam
{
/// <summary>
/// The display for player 1
/// </summary>
public RawImage display1;
/// <summary>
/// The display for player 2
/// </summary>
public RawImage display2;
/// <summary>
/// We use a different awake, since we dont want the camera to start immediatelly
/// </summary>
void Awake()
{
WebCamDevice device = WebCamTexture.devices[camdex];
tex = new WebCamTexture(device.name);
display.texture = tex;
}
/// <summary>
/// Hangman uses two different webcam_textures, we need to be able to toggle between them
/// </summary>
public void Switch_texture()
{
if(display == display1)
{
display = display2;
}
else
{
display = display1;
}
// Give the webcamTexture to the new webcam
display.texture = tex;
}
/// <summary>
/// Scene changing is implemented here to avoid problems with webcam
/// </summary>
public new void GotoThemeSelection()
{
//minigameList.GetIndexInMinigameList(MinigameIndex.HANGMAN);
if (tex != null)
{
if (tex.isPlaying)
{
display.texture = null;
tex.Stop();
tex = null;
}
}
SystemController.GetInstance().BackToPreviousScene();
}
}