Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Soft alpha mask for scrollview

Discussion in 'UGUI & TextMesh Pro' started by Brathnann, Oct 18, 2016.

  1. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,144
    I was looking at https://bitbucket.org/ddreaper/unity-ui-extensions/wiki/Controls/SoftAlphaMask however, I can't seem to get it to work with a scrollview.

    I have a standard ui scrollview with the scroll view -> viewport -> content on it. The content has a grid layout and a content size fitter. The scrollview "sits" inside a background image that has a bit of curve to it. The goal is to get the mask to also match this curve.

    Using the standard mask, we get jagged lines since the alpha is either on or off. I can't seem to get the SoftAlphaMask to work though with this setup, so I was curious if anybody had another solution for this or knew a way to get this SoftAlphaMask from the ui Extensions project to work.

    Thank you for your help.
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,144
    Still could use some help on this. It looks like it might be possible with shaders, but I have not had much luck with the few I have found. I did see that Unity may have something in their new 2D experimental tools, but that is still in early beta and may not be the best option right now, nor is there currently an estimated release date.
     
  3. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
  4. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,144
    Yeah, I had looked at those. The $10 one is actually also provided in the UI Extensions project, but I couldn't get it to work after trying several things. The $20 one does show some examples that is probably what the boss wants(the scrollview with alpha masking allowed), so it might be an option if we can't come up with another choice.

    Thanks for the suggestions.
     
  5. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    226
    It's a bit too late, but yet another masking Asset has been published recently:
    https://www.assetstore.unity3d.com/en/#!/content/80667

    It's specialized to work with Unity UI. It behaves in the same way as Unity's standard mask but supports alpha. If you use standard Mask, you can just replace it with Soft Mask and everything should work. If you have disabled 'Show Mask Graphic' flag, you should also disable Graphic when using Soft Mask, as described in the documentation.

    Well, that's enough advertising :)

    What about https://bitbucket.org/ddreaper/unity-ui-extensions/wiki/Controls/SoftAlphaMask (thanks for the link, by the way!), I have read SoftMaskScript.cs. As I understand, you should set viewport's RectTransform as MaskArea property and the mask texture as AlphaMask property. The script should be added to every masked element, not to the mask. It would be a bit difficult to use if you have a complex UI hierarchy, especially if it's changed on-the-fly, but, for simple cases, that should work.
     
    Last edited: Feb 6, 2017
    FurionTheGreatest likes this.
  6. FanCorp

    FanCorp

    Joined:
    Oct 20, 2014
    Posts:
    1
    zxkne thank you very much.
     
    zxkne likes this.
  7. IlisanVlad

    IlisanVlad

    Joined:
    Dec 3, 2017
    Posts:
    30
  8. Button79

    Button79

    Joined:
    Nov 26, 2018
    Posts:
    1