- Home /
Question by
AnomalyGraphics · Oct 31, 2018 at 11:15 AM ·
c#triggervideovideotexture
Playing Video When Clicked (Stay Paused In Scene)
So I am designing a game that requires a video to stay paused until clicked on anyone know how to do that?
Heres my current code, those are linked to buttons and stuff but I want the videos to stay paused when the scene starts until I go to the video and click on it to then play
using UnityEngine; using System.Collections; using UnityEngine.UI;
[RequireComponent(typeof(AudioSource))]
public class Script_Obsolete_SVideo : MonoBehaviour {
public float pitch = 1.0f;
public MovieTexture movie;
private AudioSource audio;
void Start()
{
GetComponent<RawImage>().texture = movie as MovieTexture;
audio = GetComponent<AudioSource>();
audio.clip = movie.audioClip;
audio.pitch = pitch;
movie.Play();
audio.Play();
}
void Update()
{
audio.pitch = pitch;
if (Input.GetKeyDown(KeyCode.P) && movie.isPlaying)
{
movie.Pause();
}
else if (Input.GetKeyDown(KeyCode.P) && !movie.isPlaying)
{
movie.Play();
}
}
public void SlowMo()
{
pitch = .5f;
}
public void Normal()
{
pitch = 1f;
}
public void SpeedUp()
{
pitch = 1.5f;
}
public void PauseVideo()
{
if (movie.isPlaying)
{
movie.Pause();
}
else if (!movie.isPlaying)
{
movie.Play();
}
}
}
Comment
You have movie.Play(); audio.Play();
right at Start()
method, so obviously it will start :) change it to pause and should be fine
Your answer
Follow this Question
Related Questions
WWW.Movie not working C# 0 Answers
Multiple Cars not working 1 Answer
How to play video on WEBGL 0 Answers
Unity 1080p Video player 1 Answer
Distribute terrain in zones 3 Answers