ProceduralMaterial 程序材质

Inherits from Material

ProceduralMaterial class.

程序材质类。

This class exposes all properties from a Procedural Material, allowing you to modify or animate them. In order to get a Procedural Material used by an object, use the Renderer.material as a ProceduralMaterial. After modifying one or more procedural properties, call RebuildTextures to update the Procedural Material to show the changes.

这个类从一个程序材质公开所有属性,允许你来修改或动画。为了获取程序材质,使用于物体,使用Renderer.material作为程序材质。修改一个或多个程序材质的属性后,调用RebuildTextures来更新程序材质,已显示所做的改变。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public string floatRangeProperty = "Saturation";
	public float cycleTime = 10;
	void Update() {
		ProceduralMaterial substance = renderer.sharedMaterial as ProceduralMaterial;
		if (substance) {
			float lerp = Mathf.PingPong(Time.time * 2 / cycleTime, 1);
			substance.SetProceduralFloat(floatRangeProperty, lerp);
			substance.RebuildTextures();
		}
	}
}
var floatRangeProperty : String = "Saturation";
var cycleTime : float = 10;

function Update () {
	var substance : ProceduralMaterial = renderer.sharedMaterial as ProceduralMaterial;
	if (substance) {
		// Make the property go up and down over time
		//使该属性随着时间的推移上下
		var lerp = Mathf.PingPong (Time.time * 2 / cycleTime, 1);
		substance.SetProceduralFloat (floatRangeProperty, lerp);
		substance.RebuildTextures ();
	}
}

Variables变量

Constructors构造器

Functions函数

Class Variables类变量

Class Functions类函数

Inherited members继承成员

Inherited Variables继承变量

Inherited Constructors继承构造器

Inherited Functions继承函数

Inherited Class Functions继承类函数

最后修改:2011年9月13日 Tuesday 12:10

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。