Author Topic: SubstanceImporter.SaveAndReimport() discards properties [5.3.2]  (Read 2142 times)

Hi,

I'm having some trouble getting changes from Editor scripts to stick with substances in Unity 5.3.2.

I've got a raft of materials (just under 1,000) that need managing from code (only in the editor, not at runtime).

Setting and saving Procedural properties works as expected, but setting regular material properties (which aren't managed by the sbsar outputs) doesn't work.

This works:
Code: [Select]
SubstanceImporter sub = AssetImporter.GetAtPath(path) as SubstanceImporter;
sub.GetMaterials()[0].SetProceduralColor("Colors_Mask_A_Output_Color", col);
sub.SaveAndReimport();

This doesn't work:
Code: [Select]
SubstanceImporter sub = AssetImporter.GetAtPath(path) as SubstanceImporter;
sub.GetMaterials()[0].SetTexture("_BumpMap", tex);
sub.SaveAndReimport();

This works, but changes are lost when selecting Reimport (or relaunching Unity):
Code: [Select]
SubstanceImporter sub = AssetImporter.GetAtPath(path) as SubstanceImporter;
sub.GetMaterials()[0].SetTexture("_BumpMap", tex);
// sub.SaveAndReimport();

I also get a raft of "Substance: m_IsProcessing should be 0 inside AwakeFromLoad()" errors when launching Unity after running these in the previous session.

I've tried AssetImporter variations and manually updating the AssetDatabase, but it's always the same result: the regular material properties of the sbsar refuse to save. This applies to non-texture settings such as _EmissionColor as well.

Any ideas?

Cheers

Hmmm, have you tried SubstanceImporter::OnShaderModified() after setting the texture? It's (not very much) documented here: http://docs.unity3d.com/ScriptReference/SubstanceImporter.OnShaderModified.html.

I think this should help.

Best Regards,
Eric

That's the stuff!

Terrific, thanks Eric :)

Cheers!

Glad you got it working !

Best Regards,
Eric