Skip to content

Commit cd8c46c

Browse files
authored
Merge pull request #107 from Unity-Technologies/UNI-24169-hide-configure-button
Uni 24169 hide configure button + set project on import
2 parents 2c8fb38 + 0e1ed9a commit cd8c46c

File tree

5 files changed

+39
-12
lines changed

5 files changed

+39
-12
lines changed

Assets/FbxExporters/Editor/InstallIntegration.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,17 +248,17 @@ public static string GetPackagePath()
248248

249249
public static string GetTempSavePath()
250250
{
251-
return System.IO.Path.Combine(Application.dataPath, FbxExporters.Review.TurnTable.TempSavePath).Replace("\\", "/");
251+
return FbxExporters.Review.TurnTable.TempSavePath.Replace("\\", "/");
252252
}
253253

254254
/// <summary>
255255
/// Gets the path to the export settings file.
256-
/// Returns an absolute path with forward slashes as path separators.
256+
/// Returns a relative path with forward slashes as path separators.
257257
/// </summary>
258258
/// <returns>The export settings path.</returns>
259259
public static string GetExportSettingsPath()
260260
{
261-
return Application.dataPath + '/' + FBX_EXPORT_SETTINGS_PATH;
261+
return FBX_EXPORT_SETTINGS_PATH;
262262
}
263263

264264
public static string GetPackageVersion()

Assets/FbxExporters/Editor/ReviewLastSavedModel.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,14 @@ private static string GetSceneFilePath ()
5151
return System.IO.Path.Combine (DefaultScenesPath, DefaultSceneName + ".unity");
5252
}
5353

54+
/// <summary>
55+
/// Gets the last saved file path as a Unity-style (only forward slashes)
56+
/// absolute path.
57+
/// </summary>
58+
/// <returns>The last saved file path.</returns>
5459
private static string GetLastSavedFilePath ()
5560
{
56-
string modelPath = FbxExporters.Editor.Integrations.GetTempSavePath ();
61+
string modelPath = Application.dataPath + "/" + TempSavePath;
5762
System.IO.FileInfo fileInfo = GetLastSavedFile (modelPath);
5863

5964
return (fileInfo != null) ? fileInfo.FullName : null;

Assets/Integrations/Autodesk/maya2017/scripts/configureUnityOneClick.mel

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ global proc configureUnityOneClick(
88
optionVar -stringValue "UnityTempSavePath" $unityTempSavePath;
99
optionVar -stringValue "UnityFbxExportSettings" $unityFbxExportSettings;
1010
optionVar -intValue "UnityOneClick_Headless" $headless;
11-
12-
// set project as the current workspace
13-
workspace -o $unityProject;
1411

1512
// configure auto load of plugin
1613
if (`pluginInfo -q -loaded unityOneClickPlugin` == false)

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

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ def loadUnityFbxExportSettings(self):
6464
"""
6565
Load the Export Settings from file
6666
"""
67-
fileName = maya.cmds.optionVar(q="UnityFbxExportSettings")
67+
projectPath = maya.cmds.optionVar(q="UnityProject")
68+
fileName = os.path.join(projectPath,"Assets", maya.cmds.optionVar(q="UnityFbxExportSettings"))
6869
if not os.path.isfile(fileName):
6970
maya.cmds.error("Failed to find Unity Fbx Export Settings at: {0}".format(fileName))
7071
return False
@@ -146,6 +147,20 @@ def beforeImport(self, retCode, file, clientData):
146147
def afterImport(self, *args, **kwargs):
147148
if self._tempPath:
148149
self.storeAttribute(self._exportSet, self._unityFbxFilePathAttr, self._tempPath)
150+
151+
# Change Unity project if fbx is from a different Unity project.
152+
# Get the project based on the folder structure (i.e. folder above Assets)
153+
head,tail = os.path.split(self._tempPath)
154+
# Check that we are not at the root directory.
155+
# os.path.dirname(head) returns the last directory name in the path,
156+
# or head if head is the root directory.
157+
while head and os.path.dirname(head) != head:
158+
if tail == "Assets":
159+
# this is a valid Unity project, so set it
160+
maya.cmds.optionVar(sv=('UnityProject', head))
161+
break
162+
head,tail = os.path.split(head)
163+
149164
if self._tempName:
150165
self.storeAttribute(self._exportSet, self._unityFbxFileNameAttr, self._tempName)
151166

@@ -161,6 +176,12 @@ def afterImport(self, *args, **kwargs):
161176

162177
def doIt(self, args):
163178
self.loadDependencies()
179+
180+
# set Unity project as the current workspace
181+
currWorkspace = maya.cmds.workspace(o=True, q=True)
182+
unityProject = maya.cmds.optionVar(q='UnityProject')
183+
if unityProject:
184+
maya.cmds.workspace(unityProject, o=True)
164185

165186
self._tempPath = None
166187
self._tempName = None
@@ -175,6 +196,9 @@ def doIt(self, args):
175196

176197
OpenMaya.MMessage.removeCallback(callbackId)
177198
OpenMaya.MMessage.removeCallback(callbackId2)
199+
200+
if currWorkspace:
201+
maya.cmds.workspace(currWorkspace, o=True)
178202

179203
@classmethod
180204
def invoke(cls):
@@ -217,7 +241,7 @@ def doIt(self, args):
217241

218242
unityAppPath = maya.cmds.optionVar(q='UnityApp')
219243
unityProjectPath = maya.cmds.optionVar(q='UnityProject')
220-
unityTempSavePath = maya.cmds.optionVar(q='UnityTempSavePath')
244+
unityTempSavePath = os.path.join(unityProjectPath, "Assets", maya.cmds.optionVar(q='UnityTempSavePath'))
221245
unityCommand = "FbxExporters.Review.TurnTable.LastSavedModel"
222246

223247
if not self.loadUnityFbxExportSettings():
@@ -235,8 +259,10 @@ def doIt(self, args):
235259
# save fbx to Assets/_safe_to_delete/
236260
savePath = unityTempSavePath
237261
maya.cmds.sysFile(savePath, makeDir=True)
238-
savePath = savePath + "/TurnTableModel.fbx"
239-
maya.mel.eval(r'file -force -options "" -typ "FBX export" -pr -es "{0}"'.format(savePath));
262+
savePath = os.path.join(savePath, "TurnTableModel.fbx")
263+
savePath = os.path.abspath(savePath)
264+
265+
maya.cmds.file(savePath, force=True, options="", typ="FBX export", pr=True, es=True)
240266

241267
if maya.cmds.about(macOS=True):
242268
# Use 'open -a' to bring app to front if it has already been started.

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ def installMenu():
5959
maya.cmds.menuItem(parent=kMainWndMenuName, label=commands.importCmd.kShortLabel, command=commands.importCmd.kScriptCommand) # @UndefinedVariable
6060
maya.cmds.menuItem(parent=kMainWndMenuName, label=commands.reviewCmd.kShortLabel, command=commands.reviewCmd.kScriptCommand) # @UndefinedVariable
6161
maya.cmds.menuItem(parent=kMainWndMenuName, label=commands.publishCmd.kShortLabel, command=commands.publishCmd.kScriptCommand) # @UndefinedVariable
62-
maya.cmds.menuItem(parent=kMainWndMenuName, label=commands.configureCmd.kShortLabel, command=commands.configureCmd.kScriptCommand) # @UndefinedVariable
6362

6463
def uninstallMenu():
6564
"""

0 commit comments

Comments
 (0)