Scripting in Unity

This section of the documentation contains details on the Substance API that we provide via the Substance plugin. Using the Substance API, you can write scripts to update and change Substance parameters at runtime. 

API Overview

Using Substance.Game

Substance.Game is the assembly that contains the classes used for scripting. These classes are as follows:

Substance.Game.Substance: References the sbsar

Substance.Game.SubstanceGraph: Individual graph in the sbsar. (used to be ProceduralMaterial in Unity 2017)

Scripting Process

  1. Create an instance of SubstanceGraph
SubstanceGraph Instance
public Substance.Game.SubstanceGraph mySubstance;

2. Set parameters on the graph instance. 

// panel color
mySubstance.SetInputColor("paint_color", color);

// panel size
mySubstance.SetInputVector2("square_open", panelSize);

// wear level
mySubstance.SetInputFloat("wear_level", wearLevel);

The value in quotes is the parameter Identifier set in Substance Designer. 

In the Unity Inspector, you can mouse over a parameter to reveal a tooltip that showcases the name of the Identifier set in Substance Designer. 

3. Queue the Substance for Rendering: QueueForRender() will add the substance graph to a queue. This list will be processed by the next call to RenderSubstancesAsync or RenderSubstancesSync.

SubstanceGraph Instance
// queue the substance to render

//render all substances async

Currently, we only support x86_64 Architecture. You need to set x86_64 in the Build Settings