Search Unity

Screen won't go back to preferred scene after playing a video.

Discussion in 'Scripting' started by Savom, Oct 4, 2015.

  1. Savom

    Savom

    Joined:
    Jan 14, 2013
    Posts:
    1
    Hi guys!
    So what I want is that after playing the video, the game will go back to the scene: ''SceneMap''. When I press LMB (like it is in the script as well) it works, but when the video ends it doesn't do anything. Does anyone know what the problem is? Thanks in advance!

    My script:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. [RequireComponent (typeof (AudioSource))]
    5.  
    6. public class Video : MonoBehaviour {
    7.    
    8.     public MovieTexture movie;
    9.  
    10.     // Use this for initialization
    11.     void Start ()
    12.     {
    13.         GetComponent<Renderer>().material.mainTexture = movie as MovieTexture;
    14.         GetComponent<AudioSource>().clip = movie.audioClip;
    15.         movie.Play();
    16.         GetComponent<AudioSource>().Play();
    17.     }
    18.    
    19.     void OnMouseDown()
    20.     {
    21.         movie.Stop();
    22.         Application.LoadLevel("SceneMap");
    23.     }
    24.    
    25.     void Update()
    26.     {
    27.         if(!movie.isPlaying) Application.LoadLevel("SceneMap");
    28.     }
    29. }
    30.