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 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
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
0
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
Add comment · 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.$$anonymous$$onoBehaviour.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.

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

Is there a better way to access the single active Toggle in a ToggleGroup? 4 Answers

A node in a childnode? 1 Answer

Maximize On Play UI is small???? 2 Answers

Unity 4.6B UI Scrollbar Usage 1 Answer

Floating Enemy Health Bars? 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