Skip to content

Commit f88bd3d

Browse files
committed
move setupUI implementation into function
- use a function and evalDeferred the function instead of using a long string
1 parent bf43ff2 commit f88bd3d

File tree

1 file changed

+32
-13
lines changed

1 file changed

+32
-13
lines changed

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

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ global string $unityImportLabel = "Import FBX file from Unity Project and auto-c
1212
global string $unityExportLabel = "Export Model to Unity";
1313

1414
global string $unityCommandsFile = "unityCommands.mel";
15-
global string $unityLoadCommandFiles;
1615
global string $unityImportMenuName = "Import";
1716
global string $unityExportMenuName = "Export";
1817
global string $unityImportCommand = "unityImport";
@@ -24,23 +23,43 @@ global proc string unityWhatsNewVersion(){
2423
}
2524

2625
global proc unitySetupUI(){
27-
global string $unityLoadCommandFiles;
28-
global string $unityCommandsFile;
29-
3026
$isHeadless = `optionVar -q "UnityFbxForMaya_Headless"`;
3127
if($isHeadless){
3228
// headless install, don't add UI
3329
return;
3430
}
3531

36-
$unityLoadCommandFiles = ("source " + $unityCommandsFile);
32+
evalDeferred -lowestPriority "unityInstallUI";
33+
}
34+
35+
global proc unityInstallUI(){
36+
global string $unityMenuName;
37+
global string $unityMenuDivider;
38+
global string $unityMenuLabel;
39+
global string $unityMenuInsertAfter;
40+
41+
global string $unityImportIconPath;
42+
global string $unityExportIconPath;
43+
global string $unityIconPath;
44+
45+
global string $unityFamilyLabel;
46+
global string $unityImportLabel;
47+
global string $unityExportLabel;
48+
49+
global string $unityCommandsFile;
50+
global string $unityImportMenuName;
51+
global string $unityExportMenuName;
52+
global string $unityImportCommand;
53+
global string $unityExportCommand;
3754

38-
evalDeferred -lowestPriority "buildFileMenu; \
39-
$parentMenu = $gMainFileMenu; \
40-
$pluginVersion = unityWhatsNewVersion(); \
41-
eval ($unityLoadCommandFiles); \
42-
menuItem -parent $parentMenu -insertAfter $unityMenuInsertAfter -divider true -longDivider false -version $pluginVersion $unityMenuDivider; \
43-
menuItem -parent $parentMenu -insertAfter $unityMenuDivider -subMenu true -label $unityMenuLabel -tearOff true -version $pluginVersion -image $unityIconPath -annotation $unityFamilyLabel $unityMenuName; \
44-
menuItem -parent $unityMenuName -label $unityImportMenuName -version $pluginVersion -image $unityImportIconPath -annotation $unityImportLabel -command $unityImportCommand; \
45-
menuItem -parent $unityMenuName -label $unityExportMenuName -version $pluginVersion -image $unityExportIconPath -annotation $unityExportLabel -command $unityExportCommand;";
55+
global string $gMainFileMenu;
56+
57+
buildFileMenu;
58+
$parentMenu = $gMainFileMenu;
59+
$pluginVersion = unityWhatsNewVersion();
60+
eval ("source " + $unityCommandsFile);
61+
menuItem -parent $parentMenu -insertAfter $unityMenuInsertAfter -divider true -longDivider false -version $pluginVersion $unityMenuDivider;
62+
menuItem -parent $parentMenu -insertAfter $unityMenuDivider -subMenu true -label $unityMenuLabel -tearOff true -version $pluginVersion -image $unityIconPath -annotation $unityFamilyLabel $unityMenuName;
63+
menuItem -parent $unityMenuName -label $unityImportMenuName -version $pluginVersion -image $unityImportIconPath -annotation $unityImportLabel -command $unityImportCommand;
64+
menuItem -parent $unityMenuName -label $unityExportMenuName -version $pluginVersion -image $unityExportIconPath -annotation $unityExportLabel -command $unityExportCommand;
4665
}

0 commit comments

Comments
 (0)