Skip to content

Commit 53ec045

Browse files
committed
code review fixes
1 parent 45846c6 commit 53ec045

File tree

1 file changed

+7
-5
lines changed
  • Assets/Integrations/Autodesk/maya2017/scripts/unityOneClick

1 file changed

+7
-5
lines changed

Assets/Integrations/Autodesk/maya2017/scripts/unityOneClick/commands.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,16 @@ def afterImport(self, *args, **kwargs):
153153

154154
# Change Unity project if fbx is from a different Unity project.
155155
# Get the project based on the folder structure (i.e. folder above Assets)
156-
splitPath = os.path.split(self._tempPath)
156+
head,tail = os.path.split(self._tempPath)
157157
# Check that we are not at the root directory.
158-
while len(splitPath) == 2 and splitPath[0] and os.path.dirname(splitPath[0]) != splitPath[0]:
159-
if splitPath[1] == "Assets" and os.path.exists(splitPath[0]):
158+
# os.path.dirname(head) returns the last directory name in the path,
159+
# or head if head is the root directory.
160+
while head and os.path.dirname(head) != head:
161+
if tail == "Assets":
160162
# this is a valid Unity project, so set it
161-
maya.cmds.optionVar(sv=('UnityProject', splitPath[0]))
163+
maya.cmds.optionVar(sv=('UnityProject', head))
162164
break
163-
splitPath = os.path.split(splitPath[0])
165+
head,tail = os.path.split(head)
164166

165167
if self._tempName:
166168
self.storeAttribute(self._exportSet, self._unityFbxFileNameAttr, self._tempName)

0 commit comments

Comments
 (0)