• 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
Question by vincentamato · Dec 20, 2014 at 05:16 PM · uiguifadeout

Fading Out UI On Play

Hi. I have a play button in my game. When the user taps the play button I want all of the UI to fade out. I have a canvas group that controls that alpha of all of these UI elements. Now all I want to do is when the user taps the play button I want all UI elements to fade out and then switch to the game scene. The game scene looks exactly the same except with none of the previous UI. How can I do this?

Comment

People who like this

0 Show 0
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
Best Answer

Answer by fafase · Dec 20, 2014 at 05:22 PM

 [SerializeField] private CanvasGroup canvasGroup = null;
 [SerializeField] private float speed = 1f;
 private bool callOnce = false;
 
 public void LoadNextScene()
 {
     if(callOnce == false){
        StartCoroutine(LoadNextSceneCoroutine());
     }
 }
 private IEnumerator LoadNextSceneCoroutine()    {
     callOnce = true;
     while(canvasGroup.alpha > 0){
         canvasGroup.alpha -= Time.deltaTime * speed;
         yield return null;
     }
     Application.LoadLevel("Scene2");
 }

Attach that to a game object and then drag it into the onClick section of the button. Choose the LoadNextScene method and I guess that should do it.

Comment

People who like this

0 Show 4 · 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 vincentamato · Dec 20, 2014 at 05:51 PM 0
Share

@fafase I keep getting 2 errors. Here they are:

  1. Assets/Scripts/GoToGameOnPlay.cs(14,25): error CS1502: The best overloaded method match for UnityEngine.MonoBehaviour.StartCoroutine(System.Collections.IEnumerator)' has some invalid arguments 2. Assets/Scripts/GoToGameOnPlay.cs(14,25): error CS1503: Argument #1' cannot convert method group' expression to type System.Collections.IEnumerator'

I also assume there is suppose to be a space between IEnumerator and LoadNextSceneCoroutine() on line 12.

Why do I keep getting these errors?

avatar image fafase · Dec 20, 2014 at 08:12 PM 0
Share

Yep my bad I fixed those. U need the space and the parenthesis.

avatar image vincentamato · Dec 20, 2014 at 08:25 PM 0
Share

@fafase There is a little pause in the transition before it goes to the game scene. Is there anything that can fix this?

avatar image Kiwasi · Dec 20, 2014 at 08:56 PM 0
Share

The pause is probably the time it takes I actually load the next scene.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

26 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

Related Questions

Unity 4.5 - Can't find UI in the “Create” list 2 Answers

Vertical scrolbar unity android 0 Answers

Issues with Google VR fading in scene,Google Cardboard black fade transition not working 1 Answer

Fading In and Out the GUI 1 Answer

Determining if Horizontal Layout Group has room for an element. 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