Author Topic: Scripting: SetInitialPreset() does not seem to work  (Read 1183 times)

Hi,
we are trying to import an sbsprs file on an SubstanceGraph object with a C# script
It doesn't give an error, but it also does not load the presets onto the graph.

This is our code:
Code: [Select]
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class SubstanceTest : MonoBehaviour
{
    public Substance.Game.SubstanceGraph sgo;
    public GameObject cube;

    void Start()
    {
        sgo.SetInitialPreset("mats_Plaster.sbsprs");
        //sgo.SetInputFloat("Plaster_Bumpiness", 0.4f);
        sgo.QueueForRender();
        sgo.RenderSync();
        Substance.Game.Substance.RenderSubstancesSync();

        cube.GetComponent<MeshRenderer>().sharedMaterial = sgo.material;
    }
}

(based on the example script in the docs)

So setting an individual property works
Code: [Select]
sgo.SetInputFloat("Plaster_Bumpiness", 0.4f);
but setting the presets file does not.

I have also added the sbsar and sbsprs files, to help you reproduce this problem if needed.

Thanks a lot in advance!
David