Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by Niamh1 · Jul 20, 2021 at 08:10 PM · coroutinemanagerscene-changetransitions

scene transition coroutine

Hello I am very new to Unity and have probably done something very simple wrong.

I have a scene transition to play between each scene when a scene change button is clicked, there's multiple scenes so I have two scripts going at the moment. One for the intro scene as I want a video logo to play and then scene change transition to play and then the other is in the game manager for all the other scene changers when both parts are needed in each scene. The intro scene one uses a different animator as otherwise the scene would open with the exit transition animation playing which I didn't want.

I have two issues, the first is in the entry scene in that the end transition plays automatically and doesn't wait first for the logo video to end. I think I must be doing something wrong with coroutines and wait time?

This is the script I am using:

public class IntroScene : MonoBehaviour { public float waitTime = 6f; // time of intro scenes public float transitionTime = 2f; //time of transition public Animator transition;

 void Start()
 {
     StartCoroutine(introWait()); 
 }

 IEnumerator introWait() // allows logo video to play first
 {
     //video plays automically so coroutine has to wait before going

     yield return new WaitForSeconds(waitTime);

     transition.GetComponent<Animator>().SetTrigger("IntroStart"); //play scene transtion
     yield return new WaitForSeconds(transitionTime); //wait time for transition to play

     SceneManager.LoadScene("00_Start"); // moves into second scene

 }

The second is with the game manager script and that Unity wants to load a scene called GameManager which doesn't exist as I thought I was using string values that I could chose which scene each button would take someone to from the inspector. I have the transition as a game object separate to the gamemanager prefab and it seems to play at the correct times but does not take to the right scene afterwards. This is the script I am using:

public class GameManager : MonoBehaviour { public static GameManager _instance;

 public float transitionTime = 1f; //time of transition

 public GameObject transition;


 void Awake() 
 {
     DontDestroyOnLoad(gameObject);

     if (_instance != null) //if the gameobject is and it isn't this one
         Destroy(this.gameObject); //destroy self (deletes temporary game managers in other scenes)

     else
     {
         _instance = this;
     }

     Debug.Log(_instance);
 }

    
     public void LoadScene(string name)
 {
     StartCoroutine(SceneChange()); //start coroutine
 }


 IEnumerator SceneChange() // sets transition to play and then change scene to string
 {
     transition.GetComponent<Animator>().SetTrigger("Start"); //play scene transition

     yield return new WaitForSeconds(transitionTime); //wait time for transition to play
     
     SceneManager.LoadScene(name); //change scene to string name
 }

 public void Quit() //quits application
 {
     Debug.Log("Application Quit");
     Application.Quit();
 }

}

Very appreciative to any and all help!

Comment
Add comment
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

0 Replies

· Add your reply
  • Sort: 

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

173 People are following this question.

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

Related Questions

Unity 5.3 and Scene transitions, how to preload a scene before entering said scene 0 Answers

Getting variable from script while keeping other code from it 1 Answer

How to deactivate a dropdown list when changing UI tabs 0 Answers

Coroutine doesn't continue after yield another coroutine 0 Answers

Coroutine not working when another Scene is first opened. 0 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