Material.shader 着色器

var shader : Shader

Description描述

The shader used by the material.

材质使用的着色器。

参考: Shader.Find 方法, Materials

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;

	}
}
// 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;
	}
}
Page last updated: 2011-5-9