Skip to content

Commit 4d3acb2

Browse files
authored
UT-3125 Relative path of texture fix (#534)
Temp file now created in same directory as final fbx to fix relative path reference in fbx file.
1 parent 6bb980b commit 4d3acb2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

com.unity.formats.fbx/Editor/FbxExporter.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3438,17 +3438,23 @@ internal int ExportAll (
34383438
Dictionary<GameObject, IExportData> exportData)
34393439
{
34403440
exportCancelled = false;
3441+
3442+
m_lastFilePath = LastFilePath;
34413443

34423444
// Export first to a temporary file
34433445
// in case the export is cancelled.
34443446
// This way we won't overwrite existing files.
3445-
try{
3446-
m_tempFilePath = Path.GetTempFileName();
3447+
try
3448+
{
3449+
// create a temp file in the same directory where the fbx will be exported
3450+
var exportDir = Path.GetDirectoryName(m_lastFilePath);
3451+
var lastFileName = Path.GetFileName(m_lastFilePath);
3452+
var tempFileName = Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) + "_" + lastFileName;
3453+
m_tempFilePath = Path.Combine(new string[] { exportDir, tempFileName });
34473454
}
34483455
catch(IOException){
34493456
return 0;
34503457
}
3451-
m_lastFilePath = LastFilePath;
34523458

34533459
if (string.IsNullOrEmpty (m_tempFilePath)) {
34543460
return 0;

0 commit comments

Comments
 (0)