public Fader(float alpha, float fadeInTime, float fadeOutTime) { alpha_ = alpha; fadeInTime_ = fadeInTime; fadeOutTime_ = fadeOutTime; updateAlpha_ = doNothing; }
//------------------------------------------------------------------------- void fadeIn() { // handle the case where the fadein time is zero (or negative) if (FadeInPeriod <= 0.0f) { Alpha = 1.0f; updateAlpha_ = waitFadeOut; return; } float timePast = time_ - FadeInTime; Alpha = timePast / FadeInPeriod; // consider the possibility of fading out while fading in if (time_ > FadeOutTime) { updateAlpha_ = fadeOut; return; } if (timePast > FadeInPeriod) { Alpha = 1.0f; updateAlpha_ = waitFadeOut; } }
//------------------------------------------------------------------------- void fadeIn() { // handle the case where the fadein time is zero (or negative) if (FadeInPeriod <= 0.0f) { Alpha = 1.0f; updateAlpha_ = waitFadeOut; return; } float timePast = time_ - FadeInTime; Alpha = timePast/FadeInPeriod; // consider the possibility of fading out while fading in if (time_ > FadeOutTime) { updateAlpha_ = fadeOut; return; } if (timePast > FadeInPeriod) { Alpha = 1.0f; updateAlpha_ = waitFadeOut; } }
//------------------------------------------------------------------------- void waitFadeIn() { if (time_ >= FadeInTime && time_ <= FadeOutTime) { Alpha = 0.0f; updateAlpha_ = fadeIn; } }
//------------------------------------------------------------------------- void waitFadeOut() { if (time_ > FadeOutTime) { updateAlpha_ = fadeOut; return; } }
//------------------------------------------------------------------------- private void fadeIn() { if (fadeInTime_ == 0.0f) { alpha_ = 1.0f; updateAlpha_ = doNothing; return; } alpha_ += deltaTime_/fadeInTime_; if (alpha_ >= 1.0f) { alpha_ = 1.0f; updateAlpha_ = doNothing; } }
//------------------------------------------------------------------------- private void fadeIn() { if (fadeInTime_ == 0.0f) { alpha_ = 1.0f; updateAlpha_ = doNothing; return; } alpha_ += deltaTime_ / fadeInTime_; if (alpha_ >= 1.0f) { alpha_ = 1.0f; updateAlpha_ = doNothing; } }
//------------------------------------------------------------------------- private void fadeOut() { if (fadeOutTime_ == 0.0f) { alpha_ = 0.0f; updateAlpha_ = doNothing; return; } alpha_ -= deltaTime_ / fadeOutTime_; if (alpha_ < 0.0f) { alpha_ = 0.0f; updateAlpha_ = doNothing; } }
//------------------------------------------------------------------------- void fadeOut() { // handle the case where the fadeout time is zero (or negative) if (FadeOutPeriod <= 0.0f) { Alpha = 0.0f; updateAlpha_ = doNothing; return; } float timePast = time_ - FadeOutTime; Alpha = 1.0f - timePast / FadeOutPeriod; if (timePast > FadeOutPeriod) { Alpha = 0.0f; updateAlpha_ = doNothing; } }
//------------------------------------------------------------------------- // METHOD DEFINITIONS //------------------------------------------------------------------------- void Awake() { updateAlpha_ = waitFadeIn; }
//------------------------------------------------------------------------- private void fadeOut() { if (fadeOutTime_ == 0.0f) { alpha_ = 0.0f; updateAlpha_ = doNothing; return; } alpha_ -= deltaTime_/fadeOutTime_; if (alpha_ < 0.0f) { alpha_ = 0.0f; updateAlpha_ = doNothing; } }
public void FadeOut() { updateAlpha_ = fadeOut; }
public void FadeIn() { updateAlpha_ = fadeIn; }
//------------------------------------------------------------------------- void fadeOut() { // handle the case where the fadeout time is zero (or negative) if (FadeOutPeriod <= 0.0f) { Alpha = 0.0f; updateAlpha_ = doNothing; return; } float timePast = time_ - FadeOutTime; Alpha = 1.0f - timePast/FadeOutPeriod; if (timePast > FadeOutPeriod) { Alpha = 0.0f; updateAlpha_ = doNothing; } }