目标值标签,用于设置当前属性内需要对比的标签的目标值,通常与 SIF 或 HIF 标签配合使用

用法

TT 主要可以传入两种类型的值,一个是 Float,一个是 Vector

使用的过程中,如果目标属性为 Color,则 TT 会把传入的 Vector 自动转换为 Color,这一步在初始化的时候已经做过了

TT(V1) : 接受单个目标值
TT(V1,V2,V3,V4) :接受四个分量的目标值

示例代码

Shader "BZShaderGUITest/ShowIf"
{
    Properties
    {   
        [Header(ShowByToggle)]
        [Toggle(_SHOWIFBYTOGGLE_ON)][Toggle]_ShowIfByToggle("ShowIfByToggle",float) = 1
        [SIF(_ShowIfByToggle)][TT(1)]_Color1("showColorByToggle", color) = (0.2,0.5,0.2,1)

        [Header(ShowByFloat)]
        [IntRange]_ShowIfByFloat("ShowByFloat",Range(-1,2))=0
        [SIF(_ShowIfByFloat,LE)]_ColorX("Color1 V<=0", color) = (0,0,0,1)
        [SIF(_ShowIfByFloat)]_Color2("Color2 V==0", color) = (1,0,1,1)
        [SIF(_ShowIfByFloat)][TT(1)]_Color3("Color3 V==1", color) = (0.5,0,0.5,1)
        [SIF(_ShowIfByFloat,GE)][TT(1)]_Color4("Color4 V>=1", color) = (0,1,1,1)

        [Header(ShowByVectorCom)]
        _ShowIfByVectorCom("ShowByCom",vector) = (1,1,1,1)
        [SIF(_ShowIfByVectorCom,GE,R)]_ColorX1("Color1 R", color) = (1,1,0,1)
        [SIF(_ShowIfByVectorCom,LE,X)]_ColorX2("Color2 X", color) = (1,0,0,1)

         [Header(ShowByColor)]
         _ShowIfByColor("ShowByColor",color)=(1,1,1,1)
         [SIF(_ShowIfByColor)][TT(1,1,1,1)]_Color10("Color10", color) = (1,1,1,1)
        
         [Header(ShowByVector)]
         _ShowIfByVec("ShowByVector",Vector) = (1,1,1,1)
         [SIF(_ShowIfByVec)][TT(1,1,1,1)]_Color20("Color20", color) = (1,1,0,1)
        
        [Header(HideByToggle)]
        [Toggle]_ShowIfByToggle30("HideIfByToggle",float) = 1
        [HIF(_ShowIfByToggle30)][TT(1)]_Color30("hideColorByToggle", color) = (1,0.5,0.2,1)    
     
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 100

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            // make fog work
            #pragma multi_compile_fog
            #pragma multi_compile_instancing
            #pragma multi_compile __ _SHOWIFBYTOGGLE_ON
            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 vertex : SV_POSITION;
            };
            half4 _Color1;

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                #if _SHOWIFBYTOGGLE_ON
                 return _Color1;
                #else
                    return half4(1,1,0,1);
                #endif
                
               
            }
            ENDCG
        }
    }
   
   CustomEditor "BZTA.BZShaderGUI"
}