1using System.Collections;
4[RequireComponent(typeof(SpriteRenderer))]
42 float distance = 1f - currentAlpha;
44 while( 1f - currentAlpha > 0.01f )
46 currentAlpha = currentAlpha + distance / Settings.m_FadeInSeconds * Time.deltaTime;
47 m_SpriteRenderer.color =
new Color(1f, 1f, 1f, currentAlpha);
51 m_SpriteRenderer.color =
new Color(1f, 1f, 1f, 1f );
67 currentAlpha = currentAlpha - distance / Settings.m_FadeOutSeconds * Time.deltaTime;
68 m_SpriteRenderer.color =
new Color( 1f, 1f, 1f, currentAlpha );
Used to obscure items when player is behind them. So that player can see the avatar clearly.
void FadeIn()
Start to fade in the object
SpriteRenderer m_SpriteRenderer
IEnumerator FadeInRoutine()
This coroutine will fade in alpha value at each keyframe.
void FadeOut()
Start to fade out the object
IEnumerator FadeOutRoutine()
This coroutine will fade out alpha value at each keyframe.
This class handle the game settings.
const float m_TargetAlpha
How it looks like after fading.