Unity使粒子特效支持UI的Mask遮罩

需要修改粒子特效的shader,修改内容如下:

Shader "xxxxxx"

{

Properties

{

        ......

        //MASK SUPPORT ADD 支持mask所需要添加的内容

        _StencilComp ("Stencil Comparison", Float)=8

        _Stencil ("Stencil ID", Float)=0

        _StencilOp ("Stencil Operation", Float)=0

        _StencilWriteMask ("Stencil Write Mask", Float)=255

        _StencilReadMask ("Stencil Read Mask", Float)=255

        _ColorMask ("Color Mask", Float)=15

        //MASK SUPPORT END

}

SubShader

{

        Tags {... "Queue"="Transparent" ...}  //注意tag需要增加这个

        //MASK SUPPORT ADD 支持mask所需要添加的内容

        Stencil

        {

                Ref [_Stencil]

                Comp [_StencilComp]

                Pass [_StencilOp]

                ReadMask [_StencilReadMask]

                WriteMask [_StencilWriteMask]

        }

        ColorMask [_ColorMask]

        //MASK SUPPORT END

        ...

}

你可能感兴趣的:(unity,ui,游戏引擎)