- Substance 3D home
- Ecosystems and Plugins
- Home
- Game Engines
- Unreal Engine
- Unreal Engine 5
- Unreal Engine 5 overview
- Unreal Engine 5 Release Notes
- Plugin Overview - UE5
- Plugin Settings - UE5
- Substance Input Image - UE5
- Material Instance Definition - UE5
- Material Template Usage - UE5
- Out-of-the-Box Material Templates
- Tiling Substance - UE5
- Substance 3D Plugin Default Templates
- Substance 3D Assets Library Usage - UE5
- Blueprints - UE5
- Unreal Engine 5 Scripting
- Installing to Source Builds
- Unreal Engine 5 overview
- Unreal Engine 4
- Unreal Engine 4 overview
- Unreal Engine 4 plugin release notes
- Unreal plugin 4.27.0.1
- Unreal plugin 4.26.0.21
- Unreal plugin 4.26.0.2
- Unreal plugin 4.26.0.1
- Unreal plugin 4.25.0.5
- Unreal plugin 4.25.0.4
- Unreal plugin 4.25.0.3
- Unreal plugin 4.24.0.3
- Unreal plugin 4.23.0.2
- Unreal plugin 4.23.0.1
- Unreal plugin 4.22.0.33
- Unreal plugin 4.22.0.32
- Unreal plugin 4.21.0.31
- Plugin Overview - UE4
- Plugin Settings - UE4
- Substance Input Image - UE4
- Material Instance Definition - UE4
- Tiling Substance - UE4
- Working with Bump Offset (Parallax) - UE4
- Working with Displacement - UE4
- Source in UE4
- Live Link in UE4
- Blueprints - UE4
- Unreal Engine 4 Scripting
- Unreal Engine 4 overview
- Unreal Engine 5
- Unity
- Unity overview
- Unity Release Notes
- Downloading Substance 3D Plugin in Unity
- Unity Plugin Overview
- Unity Preferences
- Optimization Guidelines
- Upgrading Projects/Known Issues
- Managing Substance Graphs
- Changing parameters
- Generated Textures (Packing)
- Rendering Color Space
- Using Image Inputs
- Publishing for Mobile
- Substance 3D for Unity Scripting
- Scripting in Unity (Deprecated)
- API Overview
- Scripting API
- C# Example Script
- Substance 3D Assets Library Usage
- Removing Substance Plugin
- Substance 3D in Unity Tutorials
- Physical Size in Unity
- Sharing sbsar Files Between Projects
- Unity overview
- Lumberyard
- Roblox
- Unreal Engine
- 3D Applications
- Maya
- 3ds Max
- MODO
- MODO overview
- Modo Plugin Release Notes
- Substance in MODO Overview
- Modo Installation
- Parameters
- Custom Materials
- Working with Normals
- Working with Emissive
- Bump and Displacement
- Working with References
- Animating Substances
- Copy/Duplicate Substance
- Environment and Rendering Setup
- Modo Switch Engine
- Tiling Modo textures
- MODO overview
- Cinema 4D
- Houdini
- Blender
- Blender overview
- Release Notes
- Substance in Blender Overview
- Downloading and Installing the Plugin
- Preferences
- The Substance 3D Panel
- Shortcuts and Navigation
- Workflows
- Physical size in Blender
- Substance 3D Assets Library
- Troubleshooting
- Uninstalling the Add-on
- Substance 3D Add-on for Blender Tutorials
- Blender overview
- Creative Cloud Applications
- Renderers
- Partnerships
Substance 3D for Unity Scripting
This section of the documentation contains details on the Substance 3D API that we provide via the Substance 3D plugin for Unity. Using the Substance APIs, you can write scripts to update and change Substance parameters at runtime.
API Overview
The plugin is divided into 3 different assemblies.
- Adobe.Substance
- Adobe.Substance.Editor
- Adobe.Substance.Runtime
Adobe.Substance
Contains shared components for interacting with the Substance SDK and generating matching Unity objects. It also has marshaling data structures for communicating between C# and the Substance SDK C++ API.
Adobe.Substance.Editor
Contains editor-specific classes for handling the display of information about the Unity Substance objects as well as handling the import pipeline for when sbsar files are added to the project. The SubstanceEditorEngine class is a singleton that handles the lifetime of the substance engine and all its managed instances.
Adobe.Substance.Runtime
This class has components that will handle the creation and management of Substance objects during runtime execution. The SubstanceRuntime is the equivalent of the SubstanceEditorEngine class for runtime. It will handle the initialization of the substance engine as well as the instantiation of any substance instance that user scripts will interact with.
Runtime usage
In order for the Substance Instance inputs to be modified at runtime, it is required to add a SubstanceRuntime←- Material to your scene (idealy to the same GameObject as you substance material). This class acts as a helper to set up the material using Adobe.Substance.Runtime.SubstanceRuntime singleton that manages the instantiation of Substance SDK objects at runtime.
Code examples
The following example shows how to change input parameters at runtime using the SubstanceRuntimeGraph.
Changing Parameters
using System.Collections; using System.Collections.Generic; using UnityEngine; using Adobe.Substance.Runtime; public class scifiScript: MonoBehaviour { public Adobe.Substance.Runtime.SubstanceRuntimeGraph mySubstance; // Use this for initialization void Start() { UpdateSubstance(); } public void UpdateSubstance() { // panel color mySubstance.SetInputColor("paint_color", new Color(0.237 f, 0.834 f, 0.045 f, 1.0 f)); // panel size mySubstance.SetInputVector2("square_open", new Vector2(0.101 f, 0.209 f)); // wear level mySubstance.SetInputFloat("wear_level", 0.977 f); // Submit async render. mySubstance.RenderAsync(); } }
You can also use the SubstanceRuntimeGraph to have access to input and output information about your Substance Material.
Get Input Information
using System.Collections; using System.Collections.Generic; using UnityEngine; using Adobe.Substance.Runtime; public class scifiScript: MonoBehaviour { public Adobe.Substance.Runtime.SubstanceRuntimeGraph mySubstance; // Use this for initialization void Start() { UpdateSubstance(); } public void UpdateSubstance() { SubstanceInputDescription desc = mySubstance.GetInputDescription("paint_color"); Debug.Log($ "Input: {desc.Identifier}"); Debug.Log($ "Index: {desc.Index}"); Debug.Log($ "Type: {desc.Type}"); Debug.Log($ "Label: {desc.Label}"); } }
The following example shows how to create a custom preset menu in the editor with the SubstanceEditorTools.
Creating preset controls.
using System.Collections; using System.Collections.Generic; using UnityEngine; using Adobe.Substance.Runtime; public class scifiScript: MonoBehaviour { public Adobe.Substance.Runtime.SubstanceRuntimeGraph mySubstance; // Use this for initialization void Start() { UpdateSubstance(); } public void UpdateSubstance() { SubstanceInputDescription desc = mySubstance.GetInputDescription("paint_color"); Debug.Log($ "Input: {desc.Identifier}"); Debug.Log($ "Index: {desc.Index}"); Debug.Log($ "Type: {desc.Type}"); Debug.Log($ "Label: {desc.Label}"); } }