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 el-RERS · Aug 31, 2014 at 05:03 AM · guicanvaslerp4.6

my fadeout in the new GUI system is not working...

this is a continuation of this question I made: http://answers.unity3d.com/questions/782054/making-a-fadeout-with-the-new-gui-in-46.html since for some reason I can't post in that question anymore.

Anyway, I thought of making a fadeout transition with the new GUI system by controlling the alpha of a black image component in a canvas but it's not working, my screen flickers for some reason. I'm using this code in that canvas:

  using UnityEngine;
     using System.Collections;
     using UnityEngine.UI;
     
     public class FadeOut : MonoBehaviour {
     
         private Image negro;
         public bool hacerFadeout = false;
         public float alfa;
     
     
     
         void Awake(){
     
             negro = GetComponent<Image> ();
             
         }
     
     
     
         
     
         void Update()
         {
     
             if (hacerFadeout) {
                             alfa = Mathf.Lerp (0f, 1.0f, 10f*Time.deltaTime);
                             negro.color = new Color (1.0f, 0.0f, 0.0f,alfa);
                     }
             }
     
     }

the canvas is red just to test it and I put the "hacerfadeout" variable as true manually in the inspector, again, just to test it... and when I do that, my canvas goes crazy and starts flickering!

Since my "alfa" variable is public, I can see what's going on: for some reason my Lerp function goes crazy: the values of the "alfa" variable go from 0.06 to 0.1 in a erratic manner.... what's going on?? thanks in advance :(

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

Answer by el-RERS · Aug 31, 2014 at 05:14 AM

Okay never mind guys, I figured this thing out, turns out I had to erase the "alfa" variable and put the initial color of my image in the "from" of the Lerp function! something like this:

negro.color = new Color (1.0f, 0.0f, 0.0f,Mathf.Lerp (negro.color.a, 1.0f, 10f*Time.deltaTime));

THANK YOU SO MUCH TO ALL!!

Comment
Add comment · 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

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

22 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

Related Questions

On Click paramaters disappear from button prefab? 5 Answers

How do I make it so two players can control individual input on a canvas in unity 4.6 1 Answer

Unity 4.6 adding a Canvas Text onto a gameobject prefab?? -1 Answers

How to make slider load variable on start 1 Answer

Use Unity UI For 2D Games Or Custom Objects Instead? 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