UnityEditor.SubstanceImporter.ExportPreset C# (CSharp) Method

ExportPreset() public method

Export a XML preset string with the value of all parameters of a given ProceduralMaterial to the specified folder.

public ExportPreset ( ProceduralMaterial material, string exportPath ) : void
material UnityEngine.ProceduralMaterial The ProceduralMaterial whose preset string will be saved.
exportPath string Path to a folder where the preset file will be saved. The folder will be created if it doesn't already exist.
return void
        public void ExportPreset(ProceduralMaterial material, string exportPath)
        {
            if (material == null)
            {
                throw new ArgumentException("Invalid ProceduralMaterial");
            }
            if (exportPath == "")
            {
                throw new ArgumentException("Invalid export path specified");
            }
            if (!Directory.CreateDirectory(exportPath).Exists)
            {
                throw new ArgumentException("Export folder " + exportPath + " doesn't exist and cannot be created.");
            }
            File.WriteAllText(Path.Combine(exportPath, material.name + ".sbsprs"), material.preset);
        }