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 Jaidan · Feb 05, 2015 at 08:04 PM · c#animationfadefadeinfade out

Unity Fade in Unity 6.4 UI, animations...etc

I would like to make a unity fade in , so that when my game starts the game fades in, and i can have this maybe as a scene?, so i can have it before each of my scenes. Would i need to use the animation feature to change the alpha of a black panel. I dont know but if anyone has any ideas, then please share :D, Thanks

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

1 Reply

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

Answer by Mmmpies · Feb 05, 2015 at 08:26 PM

Sure, If a static panel is OK you can put a canvas add a panel and put a CavasGroup on the base canvas.

You can fade from 0 Alpha to 1 Alpha by changing the CanvasGroup value.

 using UnityEngine.UI;  // add this at the top
 
 public CanvasGroup myCanvasGroup;
 private bool fadeIn;
 
 void Start()
 {
     fadeIn =true;
     myCanvasGroup.alpha = 0f;
 }
 
 void Update()
 {
     if(fadeIn)
     {
         myCanvasGroup.alpha = myCanvasGroup.alpha + Time.deltaTime;
         if(myCanvasGroup.alpha >= 1)
         {
              myCanvasGroup.alpha = 1;
              fadeIn = false;
         }
     }
 }
Comment
Add comment · Show 8 · 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 Jaidan · Feb 06, 2015 at 04:25 PM 0
Share

Thank you, the code works but it fades out, which i wanted aswell, but what values would i change to make in fade in? Thanks

avatar image Jaidan · Feb 06, 2015 at 04:34 PM 0
Share

And how would i have it so it comes on at specific times ?

avatar image Mmmpies · Feb 06, 2015 at 04:40 PM 0
Share

No problem, Start at 1 and do

     myCanvasGroup.alpha = myCanvasGroup.alpha - Time.deltaTime;
     if(myCanvasGroup.alpha <= 0)
     {
         myCanvasGroup.alpha = 0;
         fadeIn = false;
     }

Also if you wanted it to take 2 seconds the divide Time.deltaTime by how many seconds you want so

 myCanvasGroup.alpha = myCanvasGroup.alpha - (Time.deltaTime / 2.4f);

that example is 2.4 second.

You should also untick the interactable and blocksraycast if only using for image effects.

and to do at any time have both a fadeIn bool and a fadeOut bool, make them public and just set them when you want a menu to either fade in or out.

You'll need both the fadeIn and fadeOut sections in Update for that to work but you should have enough code to get it working.

avatar image Jaidan · Feb 06, 2015 at 04:50 PM 0
Share

I tried the code, but it made the alpha go up, because i ran the program and the alpha started at 1, which was correct, but it just keep rising? Sorry for all the questions

avatar image Jaidan · Feb 06, 2015 at 04:51 PM 0
Share

Wait, no im a idiot I forgot to add the $$anonymous$$us, so i sorted it thank you so much :D

Show more comments

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

20 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

Related Questions

save my ragdolls current pose in c# 1 Answer

Make object gradually fade from left to right,Make object gradually disappear from left to right. 0 Answers

Multiple Cars not working 1 Answer

Unity crashes when trying to fadein and fadeout sound 1 Answer

How can I fade in/out an object nonstop automatic ? 2 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