Skip to main content
Participating Frequently
August 9, 2022

Scripting issue with new 3.0.0 Unity plugin

  • August 9, 2022
  • 12 replies
  • 891 views

I am trying to upgrade my Unity project from the 2.6.0 Substance plugin integration to the new 3.0.0

I'm running the 2020.3.37 LTS Unity release. I deleted all previous installations before installing the new plugin, there are no errors in the project.
When I try writing a script with the following lines;

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Adobe.Substance.Runtime;
public class scifiScript: MonoBehaviour {
  public Adobe.Substance.Runtime.SubstanceRuntimeMaterial mySubstance;

  I do not get access to a valid component 'SubstanceRuntimeMaterial'

Instead I only have access to 'SubstanceRuntime' or 'SubstanceRuntimeGraph'.

 'SubstanceRuntimeMaterial' does not exist and causes an error.

I will try a clean installation to a fresh project as soon as I have time, but a very strange bug to encounter on a new release with new documentation.


12 replies

Participating Frequently
October 11, 2022

Thank you again @Synthoid  I've posted on the Discord. Ideally there should be an online tutorial or up to date documentation on how to assign, instantiate and dynamically modify a substance at runtime via script for the latest plugin version, it's astounding that there is nothing on the official channels yet. Again appreciate your efforts to make using the plugin easier. It used to be such an amazing tool and now it feels somewhat abandoned and under resourced.  

Synthoid
Participant
October 8, 2022

Happy to help. I've written some open source extension scripts to make working with the Substance plugin easier, but I need to update them to work better with the 3.0.0 plugin structure since the plugin kept changing classes out from under me and I got tired of trying having to redo things every couple of months 😅 Some of the features there include:

  • Inspector driven substance property referencing with a dropdown
  • Straightforward runtime graph extension methods (ie graphSO.SetFloat("floatName", 1.1f))
  • Wrapper methods for easily setting things like $outputsize in an intuitive way.

 

I've also made some improvements to things like DLL path loading so the Substance DLLs don't have to be at a preset path in the project, but those types of features are harder to implement in a sharable way since it requires adjusting plugin source code. I can share a link to that repo if people are interested though.

Participating Frequently
October 8, 2022

@Synthoid legend, thank you. There was no hope I could have worked that out by myself.

Synthoid
Participant
October 8, 2022

@miguelb69939746 To clarify, SubstanceRuntimeGraph is the example script on how to make runtime adjustments to substance assets. The actual code to make adjustments is a rather roundabout process involving calling SubstanceRuntime.Instance.InitializeInstance(graphSO); to get a SubstanceNativeHandler reference then set graph values by passing a value, the ID for the parameter (which is actually the input's index) and the ID for the graph (also the graph's index). After setting values, you can call Render() on the handler to render the substance synchronously. Asyncronous rendering is a little more complex and requires the use of System.Threading.Tasks.Task.

 

@Andrew25573414n5kr 

 

There is.a Substance 3D Discord server with channels for all the various plugins and products. The Unity channel seems to be the best place to offer feedback and seek advice. People in the community are usually quick to respond and help.

Participating Frequently
October 8, 2022

@Synthoid One more thing, While SubstanceGraphSO allows me to attach a graph to a public variable, I can't see a clear way to edit the runtime parameters of said graph. Do you have any suggestions? Thanks again for taking the time to respond.

Participating Frequently
October 8, 2022

Thank you for the info @Synthoid, wow the documentation is unbelievably out of date. The only response I've had from Adobe is to a bad review on the Asset Store... the place I cannot have a dialogue... so frustrating.

Participant
October 6, 2022

Would be possible some example about how to use SubstanceRuntimeGraph ? The documentation is outdated in this topic

Synthoid
Participant
September 27, 2022

The class you are looking for is SubstanceGraphSO. This class replaced the old SubstanceRuntimeMaterial class. SubstanceRuntimeGraph showcases how to make runtime modifications to graph properties and queue the substance for rendering.

Participating Frequently
September 17, 2022

Great I see you got around to updating the documentation, so 'SubstanceRuntimeGraph' is what I should be using.

However when I use this, as I have tried in the past, I cannot assign any of my substance graphs to a public variable, they do not seem to be the right component to allow me to drag and drop or even select through the menu. Should they work with old substance.sbsar files or do you need the  latest substance designer to create the supported format? 

Participating Frequently
September 3, 2022

I'm just confirming there is no namespace for 'SubstanceRuntimeMaterial' in the latest 3.2  plugin release, perhaps the documentation needs updating?