Hello Unity Answer community,
i have a C# script that when the game starts a video will play full screen and will stop when you hit the escape button or if the video is over and then level one will load but the video only plays half way, could you help me out and tell be what i am doing wrong.
using UnityEngine;
using System.Collections;
[RequireComponent(typeof (AudioSource))]
[RequireComponent(typeof(AudioListener))]
public class MoviePlayopaning : MonoBehaviour {
public MovieTexture movie;
private float _movieTimer;
void OnGUI () {
GUI.DrawTexture(new Rect(0,0, Screen.width, Screen.height), movie);
movie.Play();
if(Input.GetKeyUp(KeyCode.Escape) || movie.duration < _movieTimer) {
movie.Stop () ;
Application.LoadLevel ("Level1");
}
}
void Update () {
_movieTimer += Time.deltaTime;
}
}
Thank you for your time and help,
Have a nice day/night.
Hello, it gives me this error. error CS011: A namespace can only contain types and nameplate declarations
– The_CubeCan you post the line of code that its complaining about?
– iwaldropvoid Update () { _movieTimer += Time.deltaTime; } }
– The_CubeTake a look [at this question][1]. And make sure your update loop is contained within a class. [1]: http://answers.unity3d.com/questions/151609/a-namespace-can-only-contain-types-and-namespace-d.html
– iwaldropI fixed the problem and had the update loop is contained within a class but it wont load level and im not getting any errors ?
– The_Cube