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 Lance88 · Nov 01, 2012 at 12:38 PM · fadelevelload

Fade in doesnt work when loading level

Hi,

I'm trying to make a game as a project for school. Currently I have got a couple of levels, and switching levels isnt the problem. The problem is the fade in. Whenever I complete a level, the fade-out works fine, then the next level gets loaded, but without any kind of fade in. If I load the level sepperately, the fade in does work.

 fading.levelDone = true; yield WaitForSeconds(5);  
 Application.LoadLevel("Temple_of_Osiris_inside"); 
 fading.levelDone = false;

this is in the first level, fading.levelDone handles the fading in and out like this:

 function OnGUI() { 
 GUI.color = Color.black; 
 if(levelDone == true) { 
 GUI.color.a = Mathf.Lerp(0.0, 1.0, Time.time/13); // fade out 
 } 
 if(levelDone == false) { 
 GUI.color.a = Mathf.Lerp(1.0, 0.0, Time.time/2); // fade in 
 } 
 GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), theTexture);
 }


Any ideas?

Thanks in advance!

Comment
Add comment · Show 6
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 fafase · Nov 01, 2012 at 01:07 PM 0
Share

Ok, hold on, look at me in the eyes. ....$$anonymous$$mmmmmm.....hold on.....Try to think about your code real hard....think about it harder.....mmmm no I cannot read your $$anonymous$$d. Sorry you will have to post the code for us to read it and help you.

avatar image Lance88 · Nov 01, 2012 at 01:14 PM 0
Share

ok ok Im sorry

fading.levelDone = true; yield WaitForSeconds(5); Application.LoadLevel("Temple_of_Osiris_inside"); fading.levelDone = false;

this is in the first level, fading.levelDone handles the fading in and out like this:

function OnGUI() { GUI.color = Color.black; if(levelDone == true) { GUI.color.a = $$anonymous$$athf.Lerp(0.0, 1.0, Time.time/13); // fade out } if(levelDone == false) { GUI.color.a = $$anonymous$$athf.Lerp(1.0, 0.0, Time.time/2); // fade in } GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), theTexture); }

the second level has the same script, and of course, levelDone is set to false, so the fade in works when i load that level by hand

avatar image Unity_gamer · Nov 01, 2012 at 01:55 PM 0
Share

Is " levelDone " is a Static variable?

avatar image fafase · Nov 01, 2012 at 01:56 PM 0
Share

You set levelDone after LoadLevel so it does not happen. The lvel gets loaded before the value is changed.

Easiest way is to set it back in the Start function. Then when new scene loads, Start is called and the levelDone is set back to false.

avatar image Lance88 · Nov 02, 2012 at 10:11 AM 0
Share

I have a new script created and in there I have added a Start Function, and within there I set the levelDone back to false, but still the fade wont show up

Show more comments

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

13 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

Related Questions

Player Mesh fade from one color to another 1 Answer

fading between skyboxes 1 Answer

fade between scenes? 1 Answer

How to fade a gameobject containing child objects in it 0 Answers

iTween FadeTo 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