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 ArkVoid · Feb 12, 2014 at 08:14 PM · guifadefadeout

Fade out issue

Well I'll try to explain this issue as best as I can although English is not my native language (sorry about that).

Basically I'm trying to switch between two scene with Application.LoadLevel("BLABLA") and in order to smooth the transition I coded a simple Fade-In Fade-Out using a GUI.

The problem I'm having is on the fade-out to the next scene, apparently after it's done fading out and the scene is "destroyed" the first thing which disappears is the black textured GUI which makes the whole effect. And the result is for a couple milliseconds you get to see the last scene with out the gui black out which causes a "flickering" fade-out.

In a simple way : Scene One -> Starts Fade-out -> Ends Fade-out -> *For a couple of milliseconds you see Scene One-> Moves to the next scene -> Fade-in normally -> Scene Two

here are parts of my code

 void OnGUI()
     {
         if(isFadingIn)
         {
             alphaFadeValue -= Mathf.Clamp01(Time.deltaTime / fadeTime);
             GUI.color = new Color(0, 0, 0, alphaFadeValue);
             GUI.DrawTexture(rect, blackTexture);
             if(alphaFadeValue <= 0)
                 isFadingIn = false;
         }
         if(isFadingOut)
         {
             alphaFadeValue += Mathf.Clamp01(Time.deltaTime / fadeTime);
             GUI.color = new Color(0, 0, 0, alphaFadeValue);
             GUI.DrawTexture(rect, blackTexture);
             if(alphaFadeValue >= 1)
                 isFadingOut = false;
         }
     }

 public bool isDone()
     {
     //    Debug.Log(isFadingIn.ToString() + " " + isFadingOut.ToString());
         if(!isFadingIn && !isFadingOut)
             return true;
         return false;
     }
 

Switch scene part:

 void Start ()
     {
         fe = (FadeEffect)GameObject.Find ("Fade").GetComponent(typeof(FadeEffect));
         fe.fadeIn();
     }
     
     // Update is called once per frame
     void Update ()
     {
         if(fe.isDone())
         {
             if(Input.GetButtonDown("Fire1") && !startMove)
             {
 
                 startMove = true;
                 fe.fadeOut();
             }
             if(fe.isDone() && startMove)
                    Application.LoadLevel ("BlaBla");
         }
     }

I think the solution is somehow make the fade object (The script with the gui stuff) destroyed last on Application.LoadLevel("Bla") but the problem is I have no idea how to implement this kind of thing.

A lot of thanks for whoever could sort this out! Sorry for the long question!

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 DajBuzi · Feb 12, 2014 at 10:00 PM 0
Share

You can just simply do DontDestroyOnLoad(); and pack this script into some empty go.

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

19 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

Related Questions

Fade logo before main menu 2 Answers

FadeIn/FadeOut GUI Menu and Text 1 Answer

Fade in/out continously 1 Answer

GUI fade in Fade out 2 Answers

Fade GUITexture 1 Answer


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