Skip to content

Commit

Permalink
move setupUI implementation into function
Browse files Browse the repository at this point in the history
- use a function and evalDeferred the function instead of using a long
string
  • Loading branch information
vkovec committed Nov 20, 2017
1 parent bf43ff2 commit f88bd3d
Showing 1 changed file with 32 additions and 13 deletions.
45 changes: 32 additions & 13 deletions Assets/Integrations/Autodesk/maya/scripts/unitySetupUI.mel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ global string $unityImportLabel = "Import FBX file from Unity Project and auto-c
global string $unityExportLabel = "Export Model to Unity";

global string $unityCommandsFile = "unityCommands.mel";
global string $unityLoadCommandFiles;
global string $unityImportMenuName = "Import";
global string $unityExportMenuName = "Export";
global string $unityImportCommand = "unityImport";
Expand All @@ -24,23 +23,43 @@ global proc string unityWhatsNewVersion(){
}

global proc unitySetupUI(){
global string $unityLoadCommandFiles;
global string $unityCommandsFile;

$isHeadless = `optionVar -q "UnityFbxForMaya_Headless"`;
if($isHeadless){
// headless install, don't add UI
return;
}

$unityLoadCommandFiles = ("source " + $unityCommandsFile);
evalDeferred -lowestPriority "unityInstallUI";
}

global proc unityInstallUI(){
global string $unityMenuName;
global string $unityMenuDivider;
global string $unityMenuLabel;
global string $unityMenuInsertAfter;

global string $unityImportIconPath;
global string $unityExportIconPath;
global string $unityIconPath;

global string $unityFamilyLabel;
global string $unityImportLabel;
global string $unityExportLabel;

global string $unityCommandsFile;
global string $unityImportMenuName;
global string $unityExportMenuName;
global string $unityImportCommand;
global string $unityExportCommand;

evalDeferred -lowestPriority "buildFileMenu; \
$parentMenu = $gMainFileMenu; \
$pluginVersion = unityWhatsNewVersion(); \
eval ($unityLoadCommandFiles); \
menuItem -parent $parentMenu -insertAfter $unityMenuInsertAfter -divider true -longDivider false -version $pluginVersion $unityMenuDivider; \
menuItem -parent $parentMenu -insertAfter $unityMenuDivider -subMenu true -label $unityMenuLabel -tearOff true -version $pluginVersion -image $unityIconPath -annotation $unityFamilyLabel $unityMenuName; \
menuItem -parent $unityMenuName -label $unityImportMenuName -version $pluginVersion -image $unityImportIconPath -annotation $unityImportLabel -command $unityImportCommand; \
menuItem -parent $unityMenuName -label $unityExportMenuName -version $pluginVersion -image $unityExportIconPath -annotation $unityExportLabel -command $unityExportCommand;";
global string $gMainFileMenu;

buildFileMenu;
$parentMenu = $gMainFileMenu;
$pluginVersion = unityWhatsNewVersion();
eval ("source " + $unityCommandsFile);
menuItem -parent $parentMenu -insertAfter $unityMenuInsertAfter -divider true -longDivider false -version $pluginVersion $unityMenuDivider;
menuItem -parent $parentMenu -insertAfter $unityMenuDivider -subMenu true -label $unityMenuLabel -tearOff true -version $pluginVersion -image $unityIconPath -annotation $unityFamilyLabel $unityMenuName;
menuItem -parent $unityMenuName -label $unityImportMenuName -version $pluginVersion -image $unityImportIconPath -annotation $unityImportLabel -command $unityImportCommand;
menuItem -parent $unityMenuName -label $unityExportMenuName -version $pluginVersion -image $unityExportIconPath -annotation $unityExportLabel -command $unityExportCommand;
}

0 comments on commit f88bd3d

Please sign in to comment.