Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

ProceduralMaterial

Namespace: UnityEngine

/

Inherits from: Material

Description

Class for ProceduralMaterial handling.

A reference to a ProceduralMaterial is usually assigned using "renderer.sharedMaterial as ProceduralMaterial".

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 (); } }

using UnityEngine;
using System.Collections;

public class ExampleClass : 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();
        }
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public floatRangeProperty as string = 'Saturation'

	public cycleTime as float = 10

	def Update() as void:
		substance as ProceduralMaterial = (renderer.sharedMaterial as ProceduralMaterial)
		if substance:
			lerp as float = Mathf.PingPong(((Time.time * 2) / cycleTime), 1)
			substance.SetProceduralFloat(floatRangeProperty, lerp)
			substance.RebuildTextures()

Note that accessing a ProceduralMaterial via renderer.material will create a runtime clone of the original ProceduralMaterial and can negatively impact performance.

Static Variables

isSupportedCheck if ProceduralMaterials are supported on the current platform.
substanceProcessorUsageUsed to specify the Substance engine CPU usage.

Variables

animationUpdateRateSet or get the update rate in millisecond of the animated substance.
cacheSizeSet or get the Procedural cache budget.
isCachedDataAvailableIndicates whether cached data is available for this ProceduralMaterial's textures (only relevant for Cache and DoNothingAndCache loading behaviors).
isLoadTimeGeneratedShould the ProceduralMaterial be generated at load time?
isProcessingCheck if the ProceduralTextures from this ProceduralMaterial are currently being rebuilt.
isReadableSet or get the "Readable" flag for a ProceduralMaterial.
loadingBehaviorGet ProceduralMaterial loading behavior.
presetSet or get an XML string of "input/value" pairs (setting the preset rebuilds the textures).

Functions

CacheProceduralPropertySpecifies if a named ProceduralProperty should be cached for efficient runtime tweaking.
ClearCacheClear the Procedural cache.
GetGeneratedTextureThis allows to get a reference to a ProceduralTexture generated by a ProceduralMaterial using its name.
GetGeneratedTexturesGet generated textures.
GetProceduralBooleanGet a named Procedural boolean property.
GetProceduralColorGet a named Procedural color property.
GetProceduralEnumGet a named Procedural enum property.
GetProceduralFloatGet a named Procedural float property.
GetProceduralPropertyDescriptionsGet an array of descriptions of all the ProceduralProperties this ProceduralMaterial has.
GetProceduralTextureGet a named Procedural texture property.
GetProceduralVectorGet a named Procedural vector property.
HasProceduralPropertyChecks if the ProceduralMaterial has a ProceduralProperty of a given name.
IsProceduralPropertyCachedChecks if a named ProceduralProperty is cached for efficient runtime tweaking.
RebuildTexturesTriggers an asynchronous rebuild of this ProceduralMaterial's dirty textures.
RebuildTexturesImmediatelyTriggers an immediate (synchronous) rebuild of this ProceduralMaterial's dirty textures.
SetProceduralBooleanSet a named Procedural boolean property.
SetProceduralColorSet a named Procedural color property.
SetProceduralEnumSet a named Procedural enum property.
SetProceduralFloatSet a named Procedural float property.
SetProceduralTextureSet a named Procedural texture property.
SetProceduralVectorSet a named Procedural vector property.

Static Functions

StopRebuildsDiscard all the queued ProceduralMaterial rendering operations that have not started yet.

Inherited members

Variables

colorThe main material's color.
mainTextureThe material's texture.
mainTextureOffsetThe texture offset of the main texture.
mainTextureScaleThe texture scale of the main texture.
passCountHow many passes are in this material (Read Only).
renderQueueRender queue of this material.
shaderThe shader used by the material.
shaderKeywordsAdditional shader keywords set by this material.
hideFlagsShould the object be hidden, saved with the scene or modifiable by the user?
nameThe name of the object.

Functions

CopyPropertiesFromMaterialCopy properties from other material into this material.
DisableKeywordUnset a shader keyword.
EnableKeywordSet a shader keyword that is enabled by this material.
GetColorGet a named color value.
GetFloatGet a named float value.
GetIntGet a named integer value.
GetMatrixGet a named matrix value from the shader.
GetTagGet the value of material's shader tag.
GetTextureGet a named texture.
GetTextureOffsetGets the placement offset of texture propertyName.
GetTextureScaleGets the placement scale of texture propertyName.
GetVectorGet a named vector value.
HasPropertyChecks if material's shader has a property of a given name.
LerpInterpolate properties between two materials.
SetBufferSet a ComputeBuffer value.
SetColorSet a named color value.
SetFloatSet a named float value.
SetIntSet a named integer value.
SetMatrixSet a named matrix for the shader.
SetPassActivate the given pass for rendering.
SetTextureSet a named texture.
SetTextureOffsetSets the placement offset of texture propertyName.
SetTextureScaleSets the placement scale of texture propertyName.
SetVectorSet a named vector value.
GetInstanceIDReturns the instance id of the object.
ToStringReturns the name of the game object.

Static Functions

DestroyRemoves a gameobject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadMakes the object target not be destroyed automatically when loading a new scene.
FindObjectOfTypeReturns the first active loaded object of Type type.
FindObjectsOfTypeReturns a list of all active loaded objects of Type type.
InstantiateClones the object original and returns the clone.

Operators

boolDoes the object exist?
operator !=Compares if two objects refer to a different object.
operator ==Compares if two objects refer to the same.