示例#1
0
    private void FadeSplatter()
    {
        if (!_readyToFade)
        {
            return;
        }


        float currentTime = Time.time;

        if (currentTime <= _startTime + _fadeDuration)
        {
            float ratio = (currentTime - _startTime) / _fadeDuration;
            byte  alpha = (byte)(255f - ratio * 255);
            _spriteRenderer.color = new Color(_spriteRenderer.color.r,
                                              _spriteRenderer.color.g,
                                              _spriteRenderer.color.b,
                                              alpha);
        }
        else
        {
            _spriteRenderer.color = new Color(_spriteRenderer.color.r,
                                              _spriteRenderer.color.g,
                                              _spriteRenderer.color.b,
                                              255f);
            _readyToFade = false;

            _spriteRenderer.enabled = false;
            _crosshair.ReturnToPool(this.gameObject);
        }
    }