# Procedural Material (Substance) Scripting

**URL:** <https://discussions.unity.com/t/procedural-material-substance-scripting/458371>\
**Category:** Scripting\
**Tags:** Scripting\
**Created:** [October 17, 2011, 7:24am UTC](https://discussions.unity.com/t/procedural-material-substance-scripting/458371 "2011-10-17T07:24:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon\_99347306](https://avatars.discourse-cdn.com/v4/letter/a/e0b2c6/32.png) [@anon\_99347306](https://discussions.unity.com/u/anon_99347306)\
**Post date:** [October 17, 2011, 7:24am UTC](https://discussions.unity.com/t/procedural-material-substance-scripting/458371/1 "2011-10-17T07:24:34Z")

</div>

According to the scripting reference documentation for [ProceduralMaterials](http://unity3d.com/support/documentation/ScriptReference/ProceduralMaterial.html),

```auto
"In order to get a Procedural Material used by an object, use the Renderer.material as a ProceduralMaterial."

```

However, if I were to use the following code,

```auto
ProceduralMaterial substance = renderer.material as ProceduralMaterial;

```

The substance always returns null.

As the scripting example suggests, using sharedMaterial instead of material would work but I have more than 1 object sharing the same material and I don’t want the effect applied to all. Creating a copy of the sharedMaterial using Instantiate doesn’t work as well, the effect still gets applied to all.

Is this a bug? Is there currently a work around for this?

---

<div class="post-metadata">

**Author:** ![Jerc](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/jerc/32/537553_2.png) [@Jerc](https://discussions.unity.com/u/Jerc)\
**Post date:** [October 17, 2011, 12:31pm UTC](https://discussions.unity.com/t/procedural-material-substance-scripting/458371/2 "2011-10-17T12:31:33Z")

</div>

It is a known bug and has been fixed on our side, it will be included in the next Unity release. The only workaround for now is to create your instances in the Substance inspector offline.

---

<div class="post-metadata">

**Author:** ![anon\_99347306](https://avatars.discourse-cdn.com/v4/letter/a/e0b2c6/32.png) [@anon\_99347306](https://discussions.unity.com/u/anon_99347306)\
**Post date:** [October 19, 2011, 10:46am UTC](https://discussions.unity.com/t/procedural-material-substance-scripting/458371/3 "2011-10-19T10:46:56Z")

</div>

Alright. Thanks for the information.

---

<div class="post-metadata">

**Author:** ![Molix](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@Molix](https://discussions.unity.com/u/Molix)\
**Post date:** [March 14, 2012, 7:34pm UTC](https://discussions.unity.com/t/procedural-material-substance-scripting/458371/4 "2012-03-14T19:34:50Z")

</div>

> [@Jerc](#):
>
> It is a known bug and has been fixed on our side, it will be included in the next Unity release. The only workaround for now is to create your instances in the Substance inspector offline.

Has this been fixed? It seems that this negates nearly all the value of substances.

---

<div class="post-metadata">

**Author:** ![Jerc](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/jerc/32/537553_2.png) [@Jerc](https://discussions.unity.com/u/Jerc)\
**Post date:** [March 15, 2012, 1:06am UTC](https://discussions.unity.com/t/procedural-material-substance-scripting/458371/5 "2012-03-15T01:06:06Z")

</div>

I just tested it and it works as expected in 3.5.
