Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Play MainMenu after Movie Texture is done playing

Discussion in 'Scripting' started by manilamerc, Nov 29, 2012.

  1. manilamerc

    manilamerc

    Joined:
    Oct 4, 2012
    Posts:
    102
    All I need is to make sure the Main Menu will start after the movie. I think I need an if statement but I'm not sure. I tried using a boolean but no luck

     
  2. Landern

    Landern

    Joined:
    Dec 21, 2008
    Posts:
    354
    Code (csharp):
    1.  
    2. var isPlaying : boolean;
    3. function Start ()
    4. {
    5. /* Grab the texture attached to the GuiTexture object and play the video */
    6. guiTexture.texture.Play();  // movie wil not start on its own
    7.  
    8. /** Play the audio attached to the GuiTexture*/
    9. audio.Play();   //audio will not start on its own
    10. isPlaying = true;
    11.  
    12. }
    13.  
    14. function Update ()
    15. {
    16.   if (guiTexture.texture.isPlaying == false  isPlaying == false)
    17.   {
    18.     isPlaying = false;
    19.     Application.LoadLevel(2);
    20.   }
    21. }
    22.  
     
  3. manilamerc

    manilamerc

    Joined:
    Oct 4, 2012
    Posts:
    102
    I tried it and it still don't work, it jus shows a black screen after the video played :\
     
  4. BlankFoxGirl

    BlankFoxGirl

    Joined:
    Apr 26, 2010
    Posts:
    71
    Might I suggest creating a Coroutine (or use the Yield WaitForSeconds function) and set the timer to the duration of your movie texture? I had the same issue as you do now, and this is how I resolved it.

    Basically, when the Movie Texture is played, it remains as "playing" or isPlaying == false, until you call a MovieTexture.Stop(); function.