Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by AusAndrew19 · Jul 04, 2012 at 06:01 PM · moviescritping

How to make this script load next level after audio stops playing

Hi Guys. I found out this plays my video.

var movTexture : MovieTexture;

 function Start () {
     renderer.material.mainTexture = movTexture;
     movTexture.Play();
 }

How would i make this load the next scene after the video or audio has stoped playing. I have seen some other questions of the same idea but i can not get a definitive answer. Would love all the information you can share. thank you.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image whydoidoit · Jul 04, 2012 at 06:18 PM 0
Share

Formatted your code...

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by _EdzUp_ · Jul 04, 2012 at 07:12 PM

personally I would do a simple:


if ( movTexture.isPlaying == false ) {
   Application.LoadLevel( "MyLevel" );
}

There are several reasons this can be beneficial to other method one is simply the whole game can continue execution without being stuck in a do..while loop so for instance you could have a loverly background effect running through and once the sound stops it then moves on and loads the level.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AusAndrew19 · Jul 04, 2012 at 08:15 PM 0
Share

love it... But could ask you how would i implement this into my 1st script i linked. because im fairly new to unity and not really sure where this is to be placed.

avatar image _EdzUp_ · Jul 04, 2012 at 09:54 PM 0
Share

I would place it in function Update this way it will allow the system to check whilst its all running

avatar image
1

Answer by whydoidoit · Jul 04, 2012 at 06:05 PM

Like this:

 function Start () {
     renderer.material.mainTexture = movTexture;
     movTexture.Play();
     do
     {
          yield null;
     } while (movTexture.isPlaying);
     Application.LoadLevel(whatever);
 }
Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AlucardJay · Jul 04, 2012 at 06:11 PM 0
Share

I think that's a C# - JS hybrid =]

 function Start () {
     renderer.material.mainTexture = movTexture;
     movTexture.Play();
     yield;
     while (movTexture.isPlaying)
     {
         yield;
     }
     Application.LoadLevel(whatever);
 }
avatar image AusAndrew19 · Jul 04, 2012 at 06:15 PM 0
Share

var movTexture : $$anonymous$$ovieTexture;

function Start () { renderer.material.mainTexture = movTexture; movTexture.Play(); do { yield null; } while (movTexture.isPlaying); Application.LoadLevel(1); }

Causes a internal unity error that stops me clicking play. I remove the script from assets and it fixes the bug but i cant implement this script. Can you see something wrong with it? Because it doesnt come up with a error over the script but something about internal output = boo error

avatar image whydoidoit · Jul 04, 2012 at 06:15 PM 1
Share

Do while exists in Unity Script see this

avatar image whydoidoit · Jul 04, 2012 at 06:17 PM 1
Share

And you want to make sure a frame has passed before testing isPlaying I found something that didn't return playing on the first frame a while ago...

avatar image AlucardJay · Jul 04, 2012 at 06:22 PM 0
Share

sorry, fair enough. Just a pattern my brain recognized and said 'hey, that's C#' . Also thanks for the wait-a-frame-before-checking-isPlaying tip, good to know.

Show more comments
avatar image
0

Answer by Luci85 · Jul 04, 2012 at 06:03 PM

I would somehow measure how long the movTexture playtime is and make a counter which loads the scene after the time is lapsed.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Video Texture Loop 2 Answers

Movie script stops video half way ? 1 Answer

Have null errors 1 Answer

Importing the Island Demo 1 Answer

Make Script Disable 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges