目录索引
译文
有了这两种属性,我们就可以在着色器中定义颜色与向量了。
现在假设我们想编写一个用于在运行时更改颜色的着色器,那么,为了能够修改颜色的 RGBA 值,我们就需要为着色器添加颜色属性。
声明颜色与向量类型的语法如下所示:
// name ("display name", Color) = (R, G, B, A)
// name ("display name", Vector) = (0, 0, 0, 1)
Shader "InspectorPath/shaderName"
{
Properties
{
_Color ("Tint", Color) = (1, 1, 1, 1)
_VPos ("Vertex Position", Vector) = (0, 0, 0, 1)
}
}
在上面的例子中,我们声明了两个属性,分别是名为“_Color”的颜色类型与名为“_VPos”的向量类型。
原文对照
With this property, we can define colors and vectors in our shader.
We are going to suppose that we want to create a shader that can change color in execution time, for this we would have to add a color property where we can modify the RGBA values of the shader.
To declare colors and vectors in our shader, use the following syntax:
// name ("display name", Color) = (R, G, B, A)
// name ("display name", Vector) = (0, 0, 0, 1)
Shader "InspectorPath/shaderName"
{
Properties
{
_Color ("Tint", Color) = (1, 1, 1, 1)
_VPos ("Vertex Position", Vector) = (0, 0, 0, 1)
}
}
In this previous example, we declared two properties, a “color” called _Color and a “vector” called _VPos.
© 版权声明
文章版权归作者所有,未经允许请勿转载。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
THE END

![[udemy]在 Unity 中创建 RPG 游戏的终极指南-软件开发学习笔记](https://gamedevfan.cn/wp-content/uploads/2025/04/TheUltimateGuidetoCreatinganRPGGameinUnity.webp)
![[udemy]学习在 Unity 和 C# 中创建吸血鬼幸存者风格的游戏-软件开发学习笔记](https://gamedevfan.cn/wp-content/uploads/2025/04/LearnToCreateAVampireSurvivorsStyleGameinUnityC.webp)
![[udemy] 在 Godot 4 中创建完整的 2D 幸存者风格游戏-软件开发学习笔记](https://gamedevfan.cn/wp-content/uploads/2025/05/CreateaComplete2DSurvivorsStyleGameinGodot4.webp)
![[gamedev tv] RPG核心战斗力的创造者 :学习中级 Unity C# 编码-软件开发学习笔记](https://gamedevfan.cn/wp-content/uploads/2025/04/RPGCoreCombatCreatorLearnIntermediateUnityCCoding.png)
![[gamedev tv]Unity 2.5D 回合制角色扮演游戏-软件开发学习笔记](https://gamedevfan.cn/wp-content/uploads/2025/05/Unity2.5DTurn-BasedRPG.webp)



暂无评论内容