/// <summary> /// Make the highlighted tile "breath" (blink) by changing their alpha value. /// </summary> protected virtual void TileBreath() { if (_alpha < float.Epsilon) { // current alpha value is near 0, so set it to 0 and now go towards 1 _alpha = 0f; _alphaRampDirection = AlphaRampDirection.AlphaRampUp; } if (_alpha >= 1f) { // alpha as goes up to 1, now set to 1 and go down _alpha = 1f; _alphaRampDirection = AlphaRampDirection.AlphaRampDown; } // depending on the direction (towards 0 or towards 1), either add or subtract from the alpha value if (_alphaRampDirection == AlphaRampDirection.AlphaRampDown) { _alpha -= _blinkTick; } else { _alpha += _blinkTick; } }
protected virtual void TileBreath(Material material) { if (_alpha < float.Epsilon) { _alpha = 0f; _alphaRampDirection = AlphaRampDirection.AlphaRampUp; } if (_alpha >= 1f) { _alpha = 1f; _alphaRampDirection = AlphaRampDirection.AlphaRampDown; } var matColor = material.color; matColor.a = _alpha; material.color = matColor; if (_alphaRampDirection == AlphaRampDirection.AlphaRampDown) { _alpha -= TickAlphaQuantum; } else { _alpha += TickAlphaQuantum; } }