static function Material (contents : string) : Material
Description
Create a temporary material from a shader source string.
If you have a script which implements a custom special effect, you implement all the graphic setup
using shaders & materials. Use this function to create a custom shader & material inside your script.
After creating the material, use SetColor, SetTexture, SetFloat,
SetVector, SetMatrix to populate the shader property values.
var color =
Color.white;
function Start () {
var shaderText =
"Shader \"Alpha Additive\
" {" +
"Properties { _Color (\"Main
Color\
", Color) = (1,1,1,0) }" +
"SubShader {" +
" Tags { \"Queue\
" = \"Transparent\
" }" +
" Pass {" +
" Blend One One ZWrite Off ColorMask RGB" +
" Material { Diffuse [_Color] Ambient [_Color] }" +
" Lighting On" +
" SetTexture [_Dummy] { combine primary double, primary }" +
" }" +
"}" +
"}";
renderer.material =
new Material( shaderText );
renderer.material.color = color;
}
See Also: ShaderLab documentation.
static function Material (shader : Shader) : Material
Description
Create a temporary Material from a Shader.
If you have a script which implements a custom special effect, you implement all the graphic setup
using shaders & materials. Use this function to create a custom shader & material inside your script.
After creating the material, use SetColor, SetTexture, SetFloat,
SetVector, SetMatrix to populate the shader property values.
var shader :
Shader;
var texture :
Texture;
var color :
Color;
function Start () {
renderer.material =
new Material (shader);
renderer.material.mainTexture = texture;
renderer.material.color = color;
}
static function Material (source : Material) : Material
Description
Create a temporary Material by copying the shader and all properties from the source Material.