Legacy Documentation: Version 4.6.2
Language: English
  • C#
  • JS
  • Boo

Script language

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

ProceduralMaterial

Namespace: UnityEngine

/

Inherits from: Material

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

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

isSupported Check if ProceduralMaterials are supported on the current platform.
substanceProcessorUsage Used to specify the Substance engine CPU usage.

Variables

animationUpdateRate Set or get the update rate in millisecond of the animated substance.
cacheSize Set or get the Procedural cache budget.
isCachedDataAvailable Indicates whether cached data is available for this ProceduralMaterial's textures (only relevant for Cache and DoNothingAndCache loading behaviors).
isLoadTimeGenerated Should the ProceduralMaterial be generated at load time?
isProcessing Check if the ProceduralTextures from this ProceduralMaterial are currently being rebuilt.
isReadable Set or get the "Readable" flag for a ProceduralMaterial.
loadingBehavior Get ProceduralMaterial loading behavior.
preset Set or get an XML string of "input/value" pairs (setting the preset rebuilds the textures).

Functions

CacheProceduralProperty Specifies if a named ProceduralProperty should be cached for efficient runtime tweaking.
ClearCache Clear the Procedural cache.
GetGeneratedTexture This allows to get a reference to a ProceduralTexture generated by a ProceduralMaterial using its name.
GetGeneratedTextures Get generated textures.
GetProceduralBoolean Get a named Procedural boolean property.
GetProceduralColor Get a named Procedural color property.
GetProceduralEnum Get a named Procedural enum property.
GetProceduralFloat Get a named Procedural float property.
GetProceduralPropertyDescriptions Get an array of descriptions of all the ProceduralProperties this ProceduralMaterial has.
GetProceduralTexture Get a named Procedural texture property.
GetProceduralVector Get a named Procedural vector property.
HasProceduralProperty Checks if the ProceduralMaterial has a ProceduralProperty of a given name.
IsProceduralPropertyCached Checks if a named ProceduralProperty is cached for efficient runtime tweaking.
RebuildTextures Triggers an asynchronous rebuild of this ProceduralMaterial's dirty textures.
RebuildTexturesImmediately Triggers an immediate (synchronous) rebuild of this ProceduralMaterial's dirty textures.
SetProceduralBoolean Set a named Procedural boolean property.
SetProceduralColor Set a named Procedural color property.
SetProceduralEnum Set a named Procedural enum property.
SetProceduralFloat Set a named Procedural float property.
SetProceduralTexture Set a named Procedural texture property.
SetProceduralVector Set a named Procedural vector property.

Static Functions

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

Inherited members

Variables

color The main material's color.
mainTexture The material's texture.
mainTextureOffset The texture offset of the main texture.
mainTextureScale The texture scale of the main texture.
passCount How many passes are in this material (Read Only).
renderQueue Render queue of this material.
shader The shader used by the material.
shaderKeywords Additional shader keywords set by this material.
hideFlags Should the object be hidden, saved with the scene or modifiable by the user?
name The name of the object.

Functions

CopyPropertiesFromMaterial Copy properties from other material into this material.
DisableKeyword Unset a shader keyword.
EnableKeyword Set a shader keyword that is enabled by this material.
GetColor Get a named color value.
GetFloat Get a named float value.
GetInt Get a named integer value.
GetMatrix Get a named matrix value from the shader.
GetTag Get the value of material's shader tag.
GetTexture Get a named texture.
GetTextureOffset Gets the placement offset of texture propertyName.
GetTextureScale Gets the placement scale of texture propertyName.
GetVector Get a named vector value.
HasProperty Checks if material's shader has a property of a given name.
Lerp Interpolate properties between two materials.
SetBuffer Set a ComputeBuffer value.
SetColor Set a named color value.
SetFloat Set a named float value.
SetInt Set a named integer value.
SetMatrix Set a named matrix for the shader.
SetPass Activate the given pass for rendering.
SetTexture Set a named texture.
SetTextureOffset Sets the placement offset of texture propertyName.
SetTextureScale Sets the placement scale of texture propertyName.
SetVector Set a named vector value.
GetInstanceID Returns the instance id of the object.
ToString Returns the name of the game object.

Static Functions

Destroy Removes a gameobject, component or asset.
DestroyImmediate Destroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoad Makes the object target not be destroyed automatically when loading a new scene.
FindObjectOfType Returns the first active loaded object of Type type.
FindObjectsOfType Returns a list of all active loaded objects of Type type.
Instantiate Clones the object original and returns the clone.

Operators

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