Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 El-Deiablo · Jul 13, 2016 at 12:24 PM · scenelagscene-switchinggameplayfadeout

Animation Lag

I am trying to finish a scenefader which uses animations between scenes. My Gameplay Scene consists of a lot of code and stuff going on (I attached a picture below of the hierarchy so you can get a better idea of what I'm talking about). My scenefader works fine for every other scene, but when I load the gameplay scene it fades in, but then lags (with the black fade screen staying active longer than other scene switches) and does not fadeout (instantly switches to gameplay scene after loading is done). Here's a video of my project showing the issue in action - https://youtu.be/q9_cDFnENi4 - While I am pretty happy with the current setup I am also a perfectionist and want to understand what is causing this issue. Been working on this for two weeks and would really appreciate some help.

Here's some code as well:

SceneFader Code:

 using UnityEngine;
 using System.Collections;
 using UnityEngine.SceneManagement;
 
 public class SceneFader : MonoBehaviour {
 
     public static SceneFader instance;
 
     [SerializeField]
     private GameObject fadeCanvas;
 
     [SerializeField]
     private Animator fadeAnim;
 
     void Awake(){
 
         //Time.timeScale = 1f;
         MakeASingleInstance ();
 
     }
 
     void MakeASingleInstance(){
 
         if (instance != null) {
 
             Destroy (gameObject);
 
         } else {
 
             instance = this;
             DontDestroyOnLoad (gameObject);
 
         }
 
     }
 
     IEnumerator FadeInAnimate (string levelName){
 
         fadeCanvas.SetActive (true);
         fadeAnim.Play ("FadeIn");
         yield return StartCoroutine(MyCoroutine.WaitForRealSecond(0.7f));
         SceneManager.LoadScene (levelName);
         FadeOut ();
 
     }
         
     IEnumerator FadeOutAnimate(){
 
         fadeAnim.Play ("FadeOut");
         yield return StartCoroutine(MyCoroutine.WaitForRealSecond(0.7f));
         fadeCanvas.SetActive (false);
 
     }
 
     public void FadeIn(string levelName){
 
         StartCoroutine (FadeInAnimate(levelName));
 
     }
 
     public void FadeOut(){
 
         StartCoroutine (FadeOutAnimate());
 
     }
 }

MyCoroutine Code:

 using UnityEngine;
 using System.Collections;
 
 public static class MyCoroutine {
 
     public static IEnumerator WaitForRealSecond(float time){
 
         float start = Time.realtimeSinceStartup;
 
         while (Time.realtimeSinceStartup < (start + time)) {
 
             yield return null;
 
         }
 
     }
 
 }

SceneManager Code:

 using UnityEngine .SceneManagement ;
 using UnityEngine .UI;
 
 public class ChangeSceneManager : MonoBehaviour {
 
     //public static bool GameStarted=false;
 
     // Use this for initialization
     void Start () {
         
     }
 
     // Update is called once per frame
     void Update () {
 
     }
 
     public void MainMenu(){
 
         Time.timeScale = 1.0f;
         SceneFader.instance.FadeIn("Title Menu");
 
     }
 
     public void HowToPlay(){
 
         Time.timeScale = 1.0f;
         SceneFader.instance.FadeIn ("How To Play Scene");
     
     }
 
     public void Play(){
 
         //Time.timeScale = 0f;
         SceneFader.instance.FadeIn ("Gameplay");
     
 
 }
 
 }

Here's the photo of my hierarchy as well:

[1]: /storage/temp/73962-screen-shot-2016-07-13-at-20349-pm.png

screen-shot-2016-07-13-at-20349-pm.png (20.9 kB)
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 Zitoox · Jul 15, 2016 at 06:52 PM 0
Share

Your video is out of the air =/

Also, it may be a problem in Your computer. Is it powerfull enough? Sometimes the lag is caused by the "weak" hardware and we don't realize.

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

52 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

Related Questions

after click a GUI button from Menu to Game there are two screens 1 Answer

How to change Scenes in VR games 1 Answer

Key/Door to new scene 1 Answer

Setting the position of additive scenes in the hierarchy 1 Answer

Scene Loading Issue. 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