-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimpleExport.cs
38 lines (29 loc) · 1015 Bytes
/
SimpleExport.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// SPDX-FileCopyrightText: 2024 Unity Technologies and the glTFast authors
// SPDX-License-Identifier: Apache-2.0
namespace GLTFast.Documentation.Examples
{
#region SimpleExport
using UnityEngine;
using Export;
class SimpleExport : MonoBehaviour
{
[SerializeField]
string destinationFilePath;
async void Start()
{
// Example of gathering GameObjects to be exported (recursively)
var rootLevelNodes = GameObject.FindGameObjectsWithTag("ExportMe");
// GameObjectExport lets you create glTF files from GameObject hierarchies
var export = new GameObjectExport();
// Add a scene
export.AddScene(rootLevelNodes);
// Async glTF export
var success = await export.SaveToFileAndDispose(destinationFilePath);
if (!success)
{
Debug.LogError("Something went wrong exporting a glTF");
}
}
}
#endregion
}