Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

fade text unity

public Text text;
public void FadeOut()
{
    StartCoroutine(FadeOutCR);
}

private IEnumerator FadeOutCR()
{
    float duration = 0.5f; //0.5 secs
    float currentTime = 0f;
    while(currentTime < duration)
    {
        float alpha = Mathf.Lerp(1f, 0f, currentTime/duration);
        text.color = new Color(text.color.r, text.color.g, text.color.b, alpha);
        currentTime += Time.deltaTime;
        yield return null;
    }
    yield break;
}
Comment

fade text unity


// fade to transparent over 500ms.
text.CrossFadeAlpha(0.0f, 0.05f, false);

// and back over 500ms.
text.CrossFadeAlpha(1.0f, 0.05f, false);

Comment

PREVIOUS NEXT
Code Example
Csharp :: how to print a variable in c# with text 
Csharp :: c# preprocessor if not 
Csharp :: unity play particle system 
Csharp :: hide console window c# 
Csharp :: unity how to set an objects postion x,y,z 
Csharp :: c# player movement 
Csharp :: degree to radians c# 
Csharp :: unity 2d jump 
Csharp :: Retrieve url path 
Csharp :: asp.net core .gitignore 
Csharp :: c# how to simulate mouse click 
Csharp :: randomize through array in C# 
Csharp :: c# get last character of string 
Csharp :: c# convert dictionary to anonymous object 
Csharp :: laravel route redirect 
Csharp :: c# string to double 
Csharp :: unity add explosion force 
Csharp :: openfiledialog c# 
Csharp :: how to exit application c# console 
Csharp :: c# run c# code from string 
Csharp :: get value from web.config c# 
Csharp :: unity know when gameobject presed 
Csharp :: unity array to list 
Csharp :: messagebox.show c# error 
Csharp :: unity c# redirect to webiste 
Csharp :: unity get direction from one point to another 
Csharp :: check if belnd tree plaiying 
Csharp :: wpf rounded image 
Csharp :: make mesh follow wheel collider unity 
Csharp :: net.core "a path base can only be configured using iapplicationbuilder.usepathbase()" 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =