shader | Create a material with a given Shader. |
source | Create a material by copying all properties from another material. |
Create a temporary Material.
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.
See Also: Materials, Shaders.
// Creates a material from shader and texture references. var shader : Shader; var texture : Texture; var color : Color;
function Start() { var rend = GetComponent.<Renderer>();
rend.material = new Material(shader); rend.material.mainTexture = texture; rend.material.color = color; }
no example available in C#
// Creates a cube and assigns a material with a builtin Specular shader. function Start () { var cube = GameObject.CreatePrimitive(PrimitiveType.Cube); var rend = cube.GetComponent.<Renderer>(); rend.material = new Material(Shader.Find("Specular")); }
no example available in C#
Did you find this page useful? Please give it a rating: