Skip to content

Commit dc9fcca

Browse files
committed
only try to change project once
since all files will come from the same directory
1 parent ef01b7b commit dc9fcca

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

Assets/Integrations/Autodesk/maya/scripts/unityCommands.mel

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -120,23 +120,6 @@ proc importFile(string $filePathStr){
120120

121121
if ((!$isAnimFile || ($isAnimFile && $setCreated)) && $tempPath != ""){
122122
storeAttribute($unityExportSet, $UnityFbxFilePathAttr, $tempPath);
123-
124-
// Change Unity project if fbx is from a different Unity project.
125-
// Get the project based on the folder structure (i.e. folder above Assets)
126-
$head = dirname($tempPath);
127-
$tail = basename($tempPath, "");
128-
// Check that we are not at the root directory.
129-
// dirname($head) returns the last directory name in the path,
130-
// or head if head is the root directory.
131-
while ($head != "" && dirname($head) != $head){
132-
if (`strcmp $tail "Assets"` == 0){
133-
// this is a valid Unity project, so set it
134-
optionVar -sv "UnityProject" $head;
135-
break;
136-
}
137-
$head = dirname($head);
138-
$tail = basename($head, "");
139-
}
140123
}
141124

142125
if ((!$isAnimFile || ($isAnimFile && $setCreated)) && $tempName != ""){
@@ -214,6 +197,24 @@ global proc unityImport(){
214197
$filePathStr = $filePaths[$i];
215198
importFile($filePathStr);
216199
}
200+
201+
$tempPath = dirname($filePaths[0]);
202+
// Change Unity project if fbx is from a different Unity project.
203+
// Get the project based on the folder structure (i.e. folder above Assets)
204+
$head = dirname($tempPath);
205+
$tail = basename($tempPath, "");
206+
// Check that we are not at the root directory.
207+
// dirname($head) returns the last directory name in the path,
208+
// or head if head is the root directory.
209+
while ($head != "" && dirname($head) != $head){
210+
if (`strcmp $tail "Assets"` == 0){
211+
// this is a valid Unity project, so set it
212+
optionVar -sv "UnityProject" $head;
213+
break;
214+
}
215+
$head = dirname($head);
216+
$tail = basename($head, "");
217+
}
217218
}
218219

219220

0 commit comments

Comments
 (0)