Unity解决3DText穿透游戏物体的问题
程序员文章站
2022-06-27 17:51:09
一:效果演示二:实现——新建一个ShaderShader "Custom/3D Text Shader" { Properties { _MainTex ("Font Texture", 2D) = "white" {} _Color ("Text Color", Color) = (1,1,1,1) } SubShader { Tags{ "Queue"="Transparent" "IgnoreProjecto...
一:效果演示
二:实现
——新建一个Shader:3D Text Shader
Shader "Custom/3D Text Shader" {
Properties {
_MainTex ("Font Texture", 2D) = "white" {}
_Color ("Text Color", Color) = (1,1,1,1)
}
SubShader {
Tags{ "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
Lighting Off Cull Off ZWrite On Fog { Mode Off }
Blend SrcAlpha OneMinusSrcAlpha
Pass {
Color [_Color]
SetTexture [_MainTex] {
combine primary, texture * primary
}
}
}
}
——新建一个材质,选择3D Text Shader
——导入一个字体,将字体赋值给Text Mesh
——将新建的材质赋值给MeshRenderer
——将字体文件下的Font Texture赋值给Shader中的Font Texture
本文地址:https://blog.csdn.net/LLLLL__/article/details/107608805