Unity Shader Prpperties

在 Unity 的材质面板(material inspector)上可以定义一系列的参数,对应于 Shader 中的的属性(Properties)

语法如下:

Properties { Property [Property ...] }
例如:

Unity Shader Prpperties

大括号中如需定义多个属性,只需定义多个即可,常见的属性类型定义和默认值如下:

数字和滚动条类型

name ("display name", Range (min, max)) = number
name ("display name", Float) = number
name ("display name", Int) = number

颜色和向量

name ("display name", Color) = (number,number,number,number)
name ("display name", Vector) = (number,number,number,number)

纹理贴图

name ("display name", 2D) = "defaulttexture" {}
name ("display name", Cube) = "defaulttexture" {}
name ("display name", 3D) = "defaulttexture" {}

我把各个类型的都定义了一下,效果如下

Properties {
	_MyRangeValue("This is a Range", Range(0,10)) = 2.5
	_MyFloatValue("This is a Float", Float) = 1.5
	_MyIntValue("This is a Int", Int) = 2
	_MyVectorValue ("This is a Vector",Vector)=(2,1,1,1)
	_My2DValue("This is a 2D",2D) = "defaulttexture" {}
	_MyCubeValue("This is a Cube",Cube) = "defaulttexture"{}
	_My3DValue("This is a 3D",3D) = "defaulttexture"{}
}

对应于在Unity面板上的效果:

Unity Shader Prpperties


上一篇:Quartus中添加时序约束


下一篇:BUG YII2.0 $ is not defined