Skip to content

Commit

Permalink
fix remaining path issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hybridherbst committed Apr 12, 2021
1 parent c5ec25e commit 7e4878e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions UnityGLTF/Assets/UnityGLTF/Runtime/Scripts/GLTFSceneExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public GLTFRoot GetRoot()
/// <param name="fileName">The name of the GLTF file</param>
public void SaveGLB(string path, string fileName)
{
var fullPath = GetFileName(Path.Combine(path, fileName), "glb");
var fullPath = GetFileName(Path.Combine(path, fileName), ".glb");
_shouldUseInternalBufferForImages = true;

using (FileStream glbFile = new FileStream(fullPath, FileMode.Create))
Expand Down Expand Up @@ -367,7 +367,7 @@ public static uint CalculateAlignment(uint currentSize, uint byteAlignment)
public void SaveGLTFandBin(string path, string fileName)
{
_shouldUseInternalBufferForImages = false;
var fullPath = GetFileName(Path.Combine(path, fileName), "bin");
var fullPath = GetFileName(Path.Combine(path, fileName), ".bin");
var binFile = File.Create(fullPath);
_bufferWriter = new BinaryWriter(binFile);

Expand All @@ -394,7 +394,7 @@ public void SaveGLTFandBin(string path, string fileName)
_buffer.Uri = fileName + ".bin";
_buffer.ByteLength = CalculateAlignment((uint)_bufferWriter.BaseStream.Length, 4);

var gltfFile = File.CreateText(Path.ChangeExtension(fullPath, "gltf"));
var gltfFile = File.CreateText(Path.ChangeExtension(fullPath, ".gltf"));
_root.Serialize(gltfFile);

#if WINDOWS_UWP
Expand All @@ -418,10 +418,11 @@ public void SaveGLTFandBin(string path, string fileName)
/// <returns>An absolute path that has the required extension</returns>
private string GetFileName(string absolutePathThatMayHaveExtension, string requiredExtension)
{
if (!requiredExtension.StartsWith(".", StringComparison.Ordinal))
requiredExtension = "." + requiredExtension;

if (!Path.GetExtension(absolutePathThatMayHaveExtension).Equals(requiredExtension, StringComparison.OrdinalIgnoreCase))
{
return absolutePathThatMayHaveExtension + "." + requiredExtension;
}
return absolutePathThatMayHaveExtension + requiredExtension;

return absolutePathThatMayHaveExtension;
}
Expand Down

0 comments on commit 7e4878e

Please sign in to comment.