Material.shader

var shader : Shader

Description

The shader used by the material.

See Also: Shader.Find method, Materials, ShaderLab documentation.ad

JavaScript
// Toggle between Diffuse and Transparent/Diffuse shaders
// when space key is pressed

var shader1 : Shader = Shader.Find("Diffuse");
var shader2 : Shader = Shader.Find("Transparent/Diffuse");

function Update() {
if (Input.GetButtonDown("Jump")) {
if( renderer.material.shader == shader1 )
renderer.material.shader = shader2;
else
renderer.material.shader = shader1;
}
}

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
public Shader shader1 = Shader.Find("Diffuse");
public Shader shader2 = Shader.Find("Transparent/Diffuse");
void Update() {
if (Input.GetButtonDown("Jump"))
if (renderer.material.shader == shader1)
renderer.material.shader = shader2;
else
renderer.material.shader = shader1;

}
}

import UnityEngine
import System.Collections

class example(MonoBehaviour):

public shader1 as Shader = Shader.Find('Diffuse')

public shader2 as Shader = Shader.Find('Transparent/Diffuse')

def Update():
if Input.GetButtonDown('Jump'):
if renderer.material.shader == shader1:
renderer.material.shader = shader2
else:
renderer.material.shader = shader1