Exemplo n.º 1
0
        //=================================================================================
        //更新
        //=================================================================================

        //状態を更新
        protected override void UpdateState()
        {
            //経過時間加算、残像を生成するか判定
            _elapsedTime += _ignoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime;
            if (_elapsedTime < _span)
            {
                return;
            }
            _elapsedTime = 0;

            //現在レンダラーの状態から残像の情報を作成
            AfterImageEffect2DInfo info = new AfterImageEffect2DInfo(_targetSpriteRenderer);

            //残像生成、初期化
            StaticAfterImageEffect2D afterImage = _afterImagePool.Get <StaticAfterImageEffect2D>();

            afterImage.Init(info, GetColor(_nextColorNo), GetMaterial(_nextMaterialNo), _duraction, _fadeTime, _ignoreTimeScale, ReleaseAfterImage);
            afterImage.transform.position = _targetSpriteRenderer.transform.position;

            _afterImageList.Add(afterImage);

            //次の色とマテリアルの番号を変更
            _nextColorNo++;
            _nextMaterialNo++;

            if (_nextColorNo >= _colorNum)
            {
                _nextColorNo = 0;
            }
            if (_nextMaterialNo >= _materialNum)
            {
                _nextMaterialNo = 0;
            }
        }
        //=================================================================================
        //初期化
        //=================================================================================

        /// <summary>
        /// 初期化
        /// </summary>
        public void Init(AfterImageEffect2DInfo info, Color color, Material material, float duraction, float fadeTime, bool ignoreTimeScale, Action <StaticAfterImageEffect2D> releaseAction)
        {
            base.Init(color, material, ignoreTimeScale);

            info.ApplySprite(_spriteRenderer);
            info.ApplyTransform(transform);

            _initialAlpha = _spriteRenderer.color.a;

            _duraction     = duraction;
            _fadeTime      = fadeTime;
            _releaseAction = releaseAction;

            _elapsedTime = 0;

            UpdateState();
        }