首页 > 解决方案 > 在图像后面隐藏 UI 元素

问题描述

我试图实现将我的 UI 元素(如文本、图像等)隐藏在另一个透明图像后面。问题是我使用的是最新的 Unity 版本,而这些自定义着色器对隐藏 UI 着色器没有影响。我申请测试的两个自定义着色器是:

Shader "Custom/DepthReserve"
{
    Properties
    {
    }
    SubShader
    {
        Tags { "RenderType" = "Opaque" "Queue"="Geometry-1" }
        LOD 100

        Blend Zero One

        Pass
        {

        }
    }
}

Shader "Custom/InvisibleMask" {
  SubShader {
    // draw after all opaque objects (queue = 2001):
    Tags { "Queue"="Geometry+1" }
    Pass {
      Blend Zero One // keep the image behind it
    }
  } 
}

那么有没有办法使用透明图像来隐藏文本、图像甚至游戏对象呢?

标签: c#unity3d

解决方案


推荐阅读