Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Вариант№1
- private IEnumerator FadeIn()
- {
- _alarm.Play();
- while (_playerInAlarm && _alarm.volume < _maxVolume)
- {
- _alarm.volume += _fadeSpeed * Time.deltaTime;
- yield return null;
- }
- }
- private IEnumerator FadeOut()
- {
- while (!_playerInAlarm && _alarm.volume > 0)
- {
- _alarm.volume -= _fadeSpeed * Time.deltaTime;
- yield return null;
- }
- _alarm.Stop();
- }
- // Вариант №2.
- private IEnumerator ExecuteAlarm()
- {
- if (_playerInAlarm == true)
- {
- _alarm.Play();
- while (_alarm.volume < _maxVolume)
- {
- _alarm.volume += _fadeSpeed * Time.deltaTime;
- if (_playerInAlarm == false)
- yield break;
- yield return null;
- }
- }
- else
- {
- while (_alarm.volume > 0)
- {
- _alarm.volume -= _fadeSpeed * Time.deltaTime;
- if (_playerInAlarm == true)
- yield break;
- yield return null;
- }
- }
- _alarm.Stop();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement