title: Applying gradient effect on scroll text in Unity2D
body: <p>I made <a href="https://media.giphy.com/media/JGLBFru9y9mlPeKw7J/giphy.gif" rel="nofollow noreferrer">this</a> gradient effect. I used SoftMask to mark the <a href="https://prnt.sc/syHnaW787EHq" rel="nofollow noreferrer">place</a> I want to cover with the background getting the gradient effect on text. I know it would be easier to just use image background and make a gradient in photoshop (<a href="https://stackoverflow.com/a/24359737/7600110">example</a>). But what if I want things to be more dynamic? For example, I have a video in the background that on click pauses and shows up the same scroll text. Now, the tool that I made wouldn't work because the background in this scenario would be different. I've been searching for a shader that could do the trick, but couldn't find any. Is Unity even capable of doing something like this? The effect is pretty obvious and looks easy to make, but man in was pain in the a** to make this work efficiently.</p>
  <p>The gradient effect function:</p>
  <pre><code>private void FadeOutTextGradiantAndArrow(Vector2 scrollRectValue)
  {
      var contentY = _textScrollViewContent.anchoredPosition.y;
      var contentMaxY = _textScrollViewContent.rect.height - _textScrollView.GetComponent&lt;RectTransform&gt;().rect.height;
      var gradientHeight = _softMaskCanvasGroup.GetComponent&lt;RectTransform&gt;().rect.height;
      var contentYSkewed = contentY - (contentMaxY - gradientHeight);
      var positionPercentage = contentYSkewed / gradientHeight;
  
      if (contentMaxY - gradientHeight &lt; contentY)
      {
          _softMaskCanvasGroup.alpha = 1 - positionPercentage;
          _arrowBelowTextCanvasGroup.alpha = _softMaskCanvasGroup.alpha;
      }
      else
      {
          _softMaskCanvasGroup.alpha = 1;
          _arrowBelowTextCanvasGroup.alpha = _softMaskCanvasGroup.alpha;
      }
  }
  </code></pre>