Skip to content

Instantly share code, notes, and snippets.

@nicloay
Created April 12, 2018 11:08
Show Gist options
  • Save nicloay/d5b6a664c200f1ae510e70a872d5d3c0 to your computer and use it in GitHub Desktop.
Save nicloay/d5b6a664c200f1ae510e70a872d5d3c0 to your computer and use it in GitHub Desktop.
Invert mask on UI element
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;
public class InvertedMaskImage : Image {
public override Material materialForRendering
{
get
{
Material result = base.materialForRendering;
result.SetInt("_StencilComp", (int)CompareFunction.NotEqual);
return result;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment