Is your feature request related to a problem? Please describe.
Ability to Export a gameobject from code and not only from MenuEntries
Describe the solution you'd like
MenuEntries.cs should be made public and public Export function should be added. This can probably replace existing Export method as the path is optional parameter so non breaking.
public static void Export(bool binary, string name, GameObject[] gameObjects, string path = "")
{
var extension = binary ? k_GltfBinaryExtension : k_GltfExtension;
path = EditorUtility.SaveFilePanel(
"glTF Export Path",
SaveFolderPath,
$"{name}.{extension}",
extension
);
if (!string.IsNullOrEmpty(path))
{
SaveFolderPath = Directory.GetParent(path)?.FullName;
var settings = GetDefaultSettings(binary);
var goSettings = new GameObjectExportSettings { OnlyActiveInHierarchy = false };
var export = new GameObjectExport(settings, gameObjectExportSettings: goSettings, logger: new ConsoleLogger());
export.AddScene(gameObjects, name);
var success = AsyncHelpers.RunSync(() => export.SaveToFileAndDispose(path));
#if GLTF_VALIDATOR
if (success)
{
var report = Validator.Validate(path);
report.Log();
}
#endif
}
}
Is your feature request related to a problem? Please describe.
Ability to Export a gameobject from code and not only from MenuEntries
Describe the solution you'd like
MenuEntries.cs should be made public and public Export function should be added. This can probably replace existing Export method as the path is optional parameter so non breaking.