UnityGLTF
UnityGLTF copied to clipboard
Export to .glb file and Import: Mesh scale has negative X and Z component
At run-time, I try to export a GameObject into a GLB file and re-import it later. But the re-imported GameObject has a negative X and Z component.
This is the code I used for export:
GLTFSceneExporter exporter = new GLTFSceneExporter(
gos.ToList<GameObject>().Select(x => x.transform).ToArray(),
(Texture texture) => { return texture.name; });
exporter.SaveGLB(Path.GetDirectoryName(fullFilePath), Path.GetFileNameWithoutExtension(fullFilePath));
And this is the code I used for import (modified from GLTFImporter.cs):
using (var stream = File.OpenRead(expandedFilePath))
{
GLTFRoot gLTFRoot = GLTFParser.ParseJson(stream);
var loader = new GLTFSceneImporter(gLTFRoot, fileLoader, stream);
loader.MaximumLod = 300;
// HACK: Force the coroutine to run synchronously in the editor
var stack = new Stack<IEnumerator>();
stack.Push(loader.LoadScene(isMultithreaded: true));
while (stack.Count > 0)
{
var enumerator = stack.Pop();
if (enumerator.MoveNext())
{
stack.Push(enumerator);
var subEnumerator = enumerator.Current as IEnumerator;
if (subEnumerator != null)
{
stack.Push(subEnumerator);
}
}
}
return loader.LastLoadedScene;
}
Are you still running into this issue?
Cleaning up old issues. Haven't gotten a response in a long time.