/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ /*! Material Export. */ LumberyardMaterialLoadDependencies(); global proc LumberyardMaterialLoadDependencies() { eval("source cryMaterial.mel"); } //! Get the name textField of a material group. /*! /param $groupIndex The index of the material group. */ proc string LumberyardToolGetMaterialGroupItemName(int $groupIndex) { return ("materialGroupItemName" + $groupIndex); } //! Get the name text field of a material. /*! /param $groupIndex The index of the material group that the material belongs to. /param $materialIndex The index of the material within the group. */ proc string LumberyardToolGetMaterialItemName(int $groupIndex, int $materialIndex) { return ("materialItemName" + $groupIndex + "_" + $materialIndex); } //! Get the row of a material group. /*! /param $groupIndex The material group index. */ proc string LumberyardToolGetMaterialGroupItemRow(int $groupIndex) { return ("materialGroupItemRow" + $groupIndex); } //! Get the tree view row item of a material. /*! /param $groupIndex The index of the material group that the material belongs to. /param $materialIndex The index of the material within the group. */ proc string LumberyardToolGetMateriaItemRow(int $groupIndex, int $materialIndex) { return ("materialItemRow" + $groupIndex + "_" + $materialIndex); } //! Get the check box of a material group. /*! /param $groupIndex The material group index. */ proc string LumberyardToolGetMaterialGroupItemCheckBoxName(int $groupIndex) { return ("materialGroupItemCheck" + $groupIndex); } // Get the optionMenu of physicalize type of a material. /*! /param $groupIndex The index of the material group that the material belongs to. /param $materialIndex The index of the material within the group. */ proc string LumberyardGetMaterialItemPhysicalizeOptionMenu(int $groupIndex, int $materialIndex) { return ("materialItemPhysicalizeOptionMenu" + $groupIndex + "_" + $materialIndex); } //! Get the current text in the name text field of a material group. /*! /param $groupIndex The material group index. */ proc string LumberyardToolGetMaterialGroupItemNameValue(int $groupIndex) { return `textField -query -text (LumberyardToolGetMaterialGroupItemName($groupIndex))`; } //! Get the current text in the name text field of a material. /*! /param $groupIndex The index of the material group that the material belongs to. /param $materialIndex The index of the material within the group. */ proc string LumberyardToolGetMaterialItemNameValue(int $groupIndex, int $materialIndex) { return `textField -query -text (LumberyardToolGetMaterialItemName($groupIndex, $materialIndex))`; } //! Set the text in the name text field of a material group. /*! /param $groupIndex The material group index. /param $value The text value to set. */ proc LumberyardToolSetMaterialGroupItemNameValue(int $groupIndex, string $value) { textField -edit -text $value (LumberyardToolGetMaterialGroupItemName($groupIndex)); } //! Get the text in the name text field of a material. /*! /param $groupIndex The index of the material group that the material belongs to. /param $materialIndex The index of the material within the group. /param $value The text value to set. */ proc LumberyardToolSetMaterialItemNameValue(int $groupIndex, int $materialIndex, string $value) { textField -edit -text $value (LumberyardToolGetMaterialItemName($groupIndex, $materialIndex)); } //! Provide the material physicalized type strings for displaying in option menu. /*! /note In saved back-end data, the original physicalized type names are unchanged. It works correctly since the mapping order of actual types is not changed. */ proc string LumberyardExportGetMaterialPhysicalizeEnumString() { return "No Physics:Default:Proxy No Draw:No Collide:Obstruct"; } //! Get material partition name. /*! /note Ensures that the partition exists, the export selection attribute exists, and that it contains as many elements as there are material groups. */ proc string LumberyardToolsCreateMaterialPartitionIfNeeded() { string $partitionName = `cryMaterialGetPartitionName`; if( !`objExists $partitionName` ) { // Create a dummy set and add to new partition to avoid script warning. Remove the dummy set right after partition creation. sets -name "dummySet1"; partition -name $partitionName "dummySet1"; partition -removeSet $partitionName "dummySet1"; delete "dummySet1"; } if(!`attributeExists "shouldExportArray" $partitionName`) { addAttr -dataType Int32Array -longName "shouldExportArray" $partitionName; } return $partitionName; } //! Save checkBox values for material groups to material partition. /*! /param $checkBoxStates[] checkBox states of material groups. */ proc LumberyardToolSetMaterialExportSelections(int $checkBoxStates[]) { string $partitionName = `LumberyardToolsCreateMaterialPartitionIfNeeded`; string $attributeString = (size($checkBoxStates) + ""); for($i = 0; $i < size($checkBoxStates); $i++) { $attributeString += (" " + $checkBoxStates[$i]); } string $attributeName = ($partitionName + ".shouldExportArray"); string $commandString = "setAttr " + $attributeName + " -type Int32Array " + $attributeString; eval($commandString); } //! Ensures that a checkBox value exists for all material groups. proc string LumberyardToolEnsureCorrectMaterialGroupData() { string $partitionName = `LumberyardToolsCreateMaterialPartitionIfNeeded`; string $materialGroups[] = `partition -query $partitionName`; int $checkBoxStates[] = `getAttr ($partitionName + ".shouldExportArray")`; int $needsStoring = false; // If there is old data or if the data has been manipulated, set any missing groups to export by default. while(size($checkBoxStates) < size($materialGroups)) { $checkBoxStates[size($checkBoxStates)] = true; $needsStoring = true; } if($needsStoring) { LumberyardToolSetMaterialExportSelections($checkBoxStates); } return $partitionName; } //! Save the selection state of a material group with updated value. /*! /param $groupIndex The material group index. /param $value The updated state of check box. */ proc LumberyardToolSetMaterialGroupExportSelection(int $groupIndex, int $value) { string $partitionName = `LumberyardToolEnsureCorrectMaterialGroupData`; int $checkBoxValues[] = `getAttr ($partitionName + ".shouldExportArray")`; $checkBoxValues[$groupIndex] = $value; LumberyardToolSetMaterialExportSelections($checkBoxValues); } //! Get the saved selection states of all material groups. proc int[] LumberyardToolGetMaterialGroupExportSelections() { string $partitionName = `LumberyardToolEnsureCorrectMaterialGroupData`; int $checkBoxStates[] = `getAttr ($partitionName + ".shouldExportArray")`; return $checkBoxStates; } //! Remove the saved selection state of a material group. /*! /param $groupIndex The material group index. /note This should only be called when the group is about to be removed. */ proc LumberyardToolRemoveMaterialGroupExportSelection(int $groupIndex) { string $partitionName = `LumberyardToolEnsureCorrectMaterialGroupData`; int $checkBoxStates[] = `getAttr ($partitionName + ".shouldExportArray")`; intArrayRemoveAtIndex($groupIndex, $checkBoxStates); LumberyardToolSetMaterialExportSelections($checkBoxStates); } //! Ensure a custom export path attribute exists for a material group. proc int LumberyardToolEnsureCorrectMaterialGroupCustomExportPath(string $materialGroup) { if(`objExists $materialGroup`) { if (!`attributeExists "customExportPath" $materialGroup`) { addAttr -dataType "string" -longName "customExportPath" $materialGroup; } return true; } return false; } //! Ensure a custom export path attribute exists for all material groups. proc LumberyardToolEnsureAllCorrectMaterialGroupCustomExportPath() { string $partitionName = `LumberyardToolsCreateMaterialPartitionIfNeeded`; string $materialGroups[] = `partition -query $partitionName`; for ($materialGroup in $materialGroups) { LumberyardToolEnsureCorrectMaterialGroupCustomExportPath $materialGroup; } } //! Get custom export path attribute value of a material group. /*! /param $materialGroup The material group name. */ proc string LumberyardToolGetMaterialGroupCustomExportPath(string $materialGroup) { string $path; if (`LumberyardToolEnsureCorrectMaterialGroupCustomExportPath $materialGroup`) { $path = `getAttr ($materialGroup + ".customExportPath")`; } return $path; } //! Set custom export path of the selected material group using folder browser. global proc LumberyardToolSetMaterialGroupCustomExportPathFromBrowser() { global int $g_currentSelectedMaterialGroupId; if ($g_currentSelectedMaterialGroupId >= 0) { string $selectedGroup = `LumberyardToolGetMaterialGroupItemNameValue $g_currentSelectedMaterialGroupId`; string $result[] = `LumberyardBrowseForPath "" "Set Custom Export Path"`; if (`size($result)` == 1) { $folderPath = $result[0]; textField -edit -text $folderPath LUMBERYARDTOOL_MATERIALCUSTOMPATH_TEXTFIELD; setAttr -type "string" ($selectedGroup + ".customExportPath") $folderPath; } } } //! Set custom export path of the selected material group by entering in path text field. global proc LumberyardToolSetMaterialGroupCustomExportPathFromTextField() { global int $g_currentSelectedMaterialGroupId; if ($g_currentSelectedMaterialGroupId >= 0) { string $selectedGroup = `LumberyardToolGetMaterialGroupItemNameValue $g_currentSelectedMaterialGroupId`; string $folderPath = `textField -query -text LUMBERYARDTOOL_MATERIALCUSTOMPATH_TEXTFIELD`; $folderPath = `cryExportFixupPath $folderPath`; setAttr -type "string" ($selectedGroup + ".customExportPath") $folderPath; } } //! Get custom export path of the selected material group from saved data. global proc string LumberyardToolGetSelectedMaterialGroupCustomExportPath() { global int $g_currentSelectedMaterialGroupId; if ($g_currentSelectedMaterialGroupId >= 0) { string $selectedGroup = `LumberyardToolGetMaterialGroupItemNameValue $g_currentSelectedMaterialGroupId`; return `LumberyardToolGetMaterialGroupCustomExportPath $selectedGroup`; } return ""; } //! Are there existing material groups in partition. global proc int LumberyardToolMaterialGroupsExist() { string $partitionName = `LumberyardToolsCreateMaterialPartitionIfNeeded`; string $materialGroups[] = `partition -query $partitionName`; int $materialGroupCount = `size $materialGroups`; return $materialGroupCount > 0; } //! Consolidate all materials contained in groups into first group /*! /param $groups[] List of groups to consolidate into first group */ global proc string LumberyardMaterialConsolidateGroups(string $groups[]) { string $consolidatedGroup = ""; int $groupCount = `size($groups)`; if ($groupCount > 0 ) { $consolidatedGroup = $groups[0]; for( $i = 1; $i < $groupCount; $i++ ) { string $shaders[] = `sets -query $groups[$i]`; cryMaterialRemoveShadersFromGroup $groups[$i] $shaders; sets -addElement $consolidatedGroup $shaders; delete $groups[$i]; } cryMaterialRebuildGroup $consolidatedGroup; } return $consolidatedGroup; } //! Collects an array of groups that currently contain an element in shaderList /*! /param $existingGroups[] Result list of groups that have one of the shaders in it /param $shaderList[] Shaders to look for in existing groups */ global proc LumberyardMaterialCollectExistingGroupsThatContain(string $existingGroups[], string $shaderList[]) { string $partitionName = `cryMaterialGetPartitionName`; string $materialGroups[]; $materialGroups = `cryMaterialGetMaterialGroups $partitionName`; for( $materialGroup in $materialGroups ) { for ( $shader in $shaderList) { if( `sets -isMember $materialGroup $shader` ) { $existingGroups[`size($existingGroups)`] = $materialGroup; break; } } } } //! Create a material group. /*! /param $name The material group name. */ global proc string LumberyardMaterialCreateGroup(string $name) { string $partitionName = `cryMaterialGetPartitionName`; if(!`objExists $partitionName` ) { partition -name $partitionName; } int $defaultName = 0; if(`size($name)` == 0 ) { $name = `cryMaterialGetDefaultGroupName`; $defaultName = 1; } $newSet = `sets -empty -name $name`; if( $defaultName == 0 && $newSet != $name ) { confirmDialog -title "Create Group" -message ("The group was renamed from `" + $name + "` to `" + $newSet + "` due to a name clash.") -button "OK"; } partition -add $partitionName $newSet; LumberyardToolEnsureCorrectMaterialGroupCustomExportPath $newSet; return $newSet; } //! Export the selected material groups to specified material export path. /*! /param $selectedGroups[] Selected material groups to export. /param $customFilePath Specified material export path. /param $showDialogs A flag controls whether to show dialogues for overwrite warnings and how many files are exported. */ global proc LumberyardExportSelectedMaterials(string $selectedGroups[], string $customFilePath, int $showDialogs) { string $partitionName = `cryMaterialGetPartitionName`; if (!`objExists $partitionName`) { partition -name $partitionName; } // Prepare material partition by overwriting it with only selected material groups. string $cryMaterialGroups[] = `partition -query $partitionName`; for ($group in $cryMaterialGroups) { partition -removeSet $partitionName $group; } for ($group in $selectedGroups) { partition -addSet $partitionName $group; } // Do exporting work. cryExportGenerateMaterialFileToFilePath 0 $customFilePath $showDialogs; // Restore the original(all) material groups to material partition. for ($group in $selectedGroups) { partition -removeSet $partitionName $group; } for ($group in $cryMaterialGroups) { partition -addSet $partitionName $group; } } //! Gather selected materials from Hypershade or selected meshes to a string array global proc string[] LumberyardMaterialGatherMaterialsFromGeom() { string $collectedMaterials[]; string $set = `sets -empty`; if(`objExists $set`) { string $selected[]; $selected = `ls -sl`; for($rootNode in $selected) { LumberyardMaterialGatherMaterialsFromGeomRecurse $set $rootNode; } //cryMaterialGetGroupShaders handles shaders and materials as equivalent $collectedMaterials = `cryMaterialGetGroupShaders $set`; delete $set; } return $collectedMaterials; } //! Gather materials from geometry recursively /*! /param $set Name of the collection set. /param $node Root node of recursive search */ global proc LumberyardMaterialGatherMaterialsFromGeomRecurse( string $set, string $node ) { string $shaderEngines[] = `listConnections -type shadingEngine $node`; for( $shaderEngine in $shaderEngines ) { string $shaders[] = `listConnections -type lambert $shaderEngine`; for( $shader in $shaders ) { if( `sets -isMember $set $shader` ) { continue; } sets -forceElement $set $shader; } string $hwShaders[] = `listConnections -type hwShader $shaderEngine`; for( $hwShader in $hwShaders ) { if( `sets -isMember $set $hwShader` ) { continue; } sets -forceElement $set $hwShader; } } string $children[]; string $child; $children = `listRelatives -children -fullPath $node`; for ($child in $children) { LumberyardMaterialGatherMaterialsFromGeomRecurse $set $child; } } //! Add materials from string list to a material group. /*! /param $materialList List of Materials to be added to group /param $destGroup Name of destination group in partition */ global proc LumberyardMaterialAssignToPartitionGroup(string $materialList[], string $destinationGroup) { if(`objExists $destinationGroup`) { string $partitionName = `cryMaterialGetPartitionName`; for ($material in $materialList) { cryMaterialMoveShaderToGroupWithPartition $destinationGroup $material $partitionName; } } } //! Save the selection state of a material group. /*! /param $groupIndex The material group index. */ global proc LumberyardToolUpdateMaterialGroupCheckbox(int $groupIndex) { string $checkBoxName = `LumberyardToolGetMaterialGroupItemCheckBoxName $groupIndex`; int $value = `checkBox -query -value $checkBoxName`; LumberyardToolSetMaterialGroupExportSelection($groupIndex, $value); } //! Create a tree view item of a material group item and add it to the tree view. /*! /param $groupItem The material group name. /param $groupIndex The material group index. /param $shouldExport The export selection state of the group. */ proc LumberyardToolAddGroupItemToMaterialTreeView(string $groupItem, int $groupIndex, int $shouldExport) { global int $g_rowItemHeight; setParent LUMBERYARDTOOL_MATERIAL_TREEVIEW; string $rowFullName = `rowLayout -numberOfColumns 3 -columnWidth3 22 225 19 -height $g_rowItemHeight -columnAttach3 "left" "left" "left" -columnOffset3 4 0 4 (LumberyardToolGetMaterialGroupItemRow($groupIndex))`; { string $checkBoxName = `LumberyardToolGetMaterialGroupItemCheckBoxName $groupIndex`; checkBox -label "" -value $shouldExport -backgroundColor 0.5 0.5 0.5 -changeCommand ("LumberyardToolUpdateMaterialGroupCheckbox " + $groupIndex) $checkBoxName; textField -text $groupItem -width 225 -changeCommand ("LumberyardToolSetMaterialGroupName " + $groupIndex) -alwaysInvokeEnterCommandOnReturn 1 -noBackground 1 -receiveFocusCommand ("LumberyardToolMaterialTreeViewGroupItemOnFocus " + $groupIndex) `LumberyardToolGetMaterialGroupItemName $groupIndex`; button -label "X" -backgroundColor 0 0 0 -height 20 -command("LumberyardToolRemoveMaterialGroup " + $groupIndex); } scriptJob -replacePrevious -nodeDeleted $groupItem "LumberyardToolUpdateMaterialTreeView" -parent $rowFullName; } //! Create a tree view item of a material and add it to the tree view. /*! /param $item The material group name. /param $groupIndex The index of the material group that the material belongs to. /param $materialIndex The material index within the group. */ proc string LumberyardToolAddMaterialItemToMaterialTreeView(string $item, int $groupIndex, int $materialIndex) { global int $g_rowItemHeight; global float $g_UIColor[]; setParent LUMBERYARDTOOL_MATERIAL_TREEVIEW; string $rowFullName = `rowLayout -numberOfColumns 3 -columnWidth3 137 110 19 -height $g_rowItemHeight -columnAttach3 "right" "left" "left" -columnOffset3 3 0 4 -dragCallback materialItemDragCallback -dropCallback materialItemDropCallback (LumberyardToolGetMateriaItemRow($groupIndex, $materialIndex))`; { textField -text $item -width 100 -changeCommand ("LumberyardToolSetMaterialName " + $groupIndex + " " + $materialIndex) -alwaysInvokeEnterCommandOnReturn 1 -noBackground 1 -receiveFocusCommand ("LumberyardToolMaterialTreeViewMaterialItemOnFocus " + $groupIndex + " " + $materialIndex) `LumberyardToolGetMaterialItemName $groupIndex $materialIndex`; optionMenu -label "" -width 110 -backgroundColor $g_UIColor[0] $g_UIColor[1] $g_UIColor[2] -changeCommand ("LumberyardSetMaterialPhysicalizeType " + $groupIndex + " " + $materialIndex) (LumberyardGetMaterialItemPhysicalizeOptionMenu($groupIndex, $materialIndex)); { string $enumString = `LumberyardExportGetMaterialPhysicalizeEnumString`; string $tokens[]; $numTokens = `tokenize $enumString ":" $tokens`; for ($i = 0; $i < $numTokens; $i++) { menuItem -label $tokens[$i]; } LumberyardUpdateMaterialTreeViewItemPhysicalizeType $groupIndex $materialIndex; } button -label "X" -backgroundColor 0 0 0 -height 20 -command("LumberyardToolRemoveMaterial " + $groupIndex + " " + $materialIndex); } scriptJob -replacePrevious -nodeDeleted $item "LumberyardToolUpdateMaterialTreeView" -parent $rowFullName; return $rowFullName; } //! Create instruction texts for Material export list and add it global proc LumberyardToolAddMaterialInstructionTexts() { global int $g_instructionRowSpace; setParent LUMBERYARDTOOL_MATERIAL_TREEVIEW; rowColumnLayout -numberOfRows 2 -rowOffset 1 "top" 70 -columnOffset 1 "both" 62 -rowSpacing 2 $g_instructionRowSpace; text -label "Select a mesh or material and click `Add Material`"; text -label "or create a new material group by clicking `Add Group`"; } //! Check if the materials added to the group contain Maya default material "lambert1". Inform user if found and remove it from the list. /*! /param $group Name of material group /param $materials Materials added to the group */ global proc string[] LumberyardToolCheckDefaultMaterial(string $materials[]) { string $filteredMaterials[]; int $messageShown = false; for ($material in $materials) { if ($material == "lambert1") { if (!$messageShown) { string $message = "The Maya default material lambert1 cannot be added, please create a new " + "material in the Hypershade and assign it to the meshes/faces that use lambert1."; confirmDialog -title "Error occurred in adding materials to material group" -message $message -button "OK" -defaultButton "OK" -cancelButton "OK"; $messageShown = true; } } else { $filteredMaterials[`size $filteredMaterials`] = $material; } } return $filteredMaterials; } //! Create a new material group and add selected materials, if any. global proc LumberyardToolAddNewMaterialGroup() { LumberyardToolAddMaterials( false ); } //! Create a new material group and add selected materials, if any. global proc LumberyardToolAddMaterials( int $useExistingGroups) { string $materials[] = `LumberyardMaterialGatherMaterialsFromGeom`; int $createEmptySet = (`size($materials)` == 0); //Remove Lambert shaders $materials = `LumberyardToolCheckDefaultMaterial $materials`; //if the group contained only the default material, do not create the group. if (`size ($materials)` == 0 && !$createEmptySet ) { return; } string $destinationGroup = ""; if ($useExistingGroups) { string $existingGroups[]; LumberyardMaterialCollectExistingGroupsThatContain $existingGroups $materials; //find existing groups that are involved and combine them. //If no existing groups are involved then destinationGroup will be "". $destinationGroup = `LumberyardMaterialConsolidateGroups $existingGroups`; } if ($destinationGroup == "") { // make a new group string $groupName = "new_matGroup"; if (`size($materials)` > 0) { $groupName = $materials[0] + "_matGroup"; } $destinationGroup = `LumberyardMaterialCreateGroup $groupName`; } //At this point the materials have not been added, only existing groups have been combined if expected //materials that are currently not in the group will be added. LumberyardAddMaterialPhysicalizeTypes $materials; LumberyardMaterialAssignToPartitionGroup($materials, $destinationGroup); select -clear; //if user decided not to move materials and group ends up empty if ((`sets -query -size $destinationGroup` == 0) && !$createEmptySet ) { cryMaterialDeleteGroup $destinationGroup; return; } LumberyardToolUpdateMaterialTreeView; } //! Create a new material under a specific material group. /*! /param $groupIndex The index of the material group that the material will add to. */ global proc LumberyardToolAddNewMaterial(int $groupIndex) { string $groupName = `LumberyardToolGetMaterialGroupItemNameValue $groupIndex`; string $materials[] = `LumberyardMaterialGatherMaterialsFromGeom`; select -clear; $materials = `LumberyardToolCheckDefaultMaterial $materials`; LumberyardAddMaterialPhysicalizeTypes $materials; LumberyardMaterialAssignToPartitionGroup($materials, $groupName); LumberyardToolUpdateMaterialTreeView; } //! Remove a specific material group. /*! /param $groupIndex The material group index. */ global proc LumberyardToolRemoveMaterialGroup(int $groupIndex) { string $group = `LumberyardToolGetMaterialGroupItemNameValue $groupIndex`; string $materials[] = `cryMaterialGetGroupShaders $group`; LumberyardRemoveMaterialPhysicalizeTypes $materials; cryMaterialDeleteGroup $group; LumberyardToolRemoveMaterialGroupExportSelection($groupIndex); LumberyardToolUpdateMaterialTreeView; } //! Remove a material from a material group. /*! /param $groupIndex The index of the material group that the material belongs to. /param $materialIndex The index of the material within the group. */ global proc LumberyardToolRemoveMaterial(int $groupIndex, int $materialIndex) { string $group = `LumberyardToolGetMaterialGroupItemNameValue $groupIndex`; string $materials[]; $materials[0] = `LumberyardToolGetMaterialItemNameValue $groupIndex $materialIndex`; LumberyardRemoveMaterialPhysicalizeTypes $materials; cryMaterialRemoveShadersFromGroup $group $materials; LumberyardToolUpdateMaterialTreeView; } //! Get the material group name from its index. /*! /param $groupIndex The material group index. */ global proc string LumberyardToolGetMaterialGroupNameFromItemId(int $groupIndex) { string $partitionName = `cryMaterialGetPartitionName`; if(`objExists $partitionName`) { string $materialGroups[]; $materialGroups = `partition -query $partitionName`; if ($groupIndex < `size($materialGroups)`) { return $materialGroups[$groupIndex]; } } return ""; } //! Get the material name from its group index and its index within the group. /*! /param $groupIndex The index of the material group that the material belongs to. /param $materialIndex The material index within the group. */ global proc string LumberyardToolGetMaterialNameFromItemId(int $groupIndex, int $materialIndex) { string $groupName = `LumberyardToolGetMaterialGroupNameFromItemId $groupIndex`; if ($groupName != "") { string $contents[] = `cryMaterialGetGroupShaders $groupName`; if ($materialIndex < `size($contents)`) { return $contents[$materialIndex]; } } return ""; } //! Rename the material group with the value retrieved from its corresponding name textField. /*! /param $groupIndex The material group index. */ global proc LumberyardToolSetMaterialGroupName(int $groupIndex) { string $currentMaterialGroupName = `LumberyardToolGetMaterialGroupNameFromItemId $groupIndex`; string $newMaterialGroupName = `LumberyardToolGetMaterialGroupItemNameValue $groupIndex`; $newMaterialGroupName = `LumberyardVerifySceneObjectRequestName $newMaterialGroupName $currentMaterialGroupName`; $currentMaterialGroupName = `rename $currentMaterialGroupName $newMaterialGroupName`; // In case Maya adjusts the name for its own validity check (possible), update the widget to reflect the latest name. LumberyardToolSetMaterialGroupItemNameValue $groupIndex $currentMaterialGroupName; } //! Rename the material name with the new name retrieved from the name text field. /*! /param $groupIndex The index of the material group that the material belongs to. /param $materialIndex The index of the material within the group. */ global proc LumberyardToolSetMaterialName(int $groupIndex, int $materialIndex) { string $currentMaterialName = `LumberyardToolGetMaterialNameFromItemId $groupIndex $materialIndex`; string $newMaterialName = `LumberyardToolGetMaterialItemNameValue $groupIndex $materialIndex`; $newMaterialName = `LumberyardVerifySceneObjectRequestName $newMaterialName $currentMaterialName`; $currentMaterialName = `rename $currentMaterialName $newMaterialName`; // In case Maya adjusts the name for its own validity check (possible), update the widget to reflect the latest name. LumberyardToolSetMaterialItemNameValue $groupIndex $materialIndex $currentMaterialName; } //! Utility function to determine if a material should be set to ProxyNoDraw physicalize properties by default /*! /param $material Name of the material to set default physicalize flags for */ proc int LumberyardIsDefaultProxyNoDraw(string $material) { if(`objExists $material` && `attributeExists "lumberyardPhysMaterial" $material`) { return true; } if(`gmatch $material "*[Pp]hys*"`) { return true; } return false; } //! Add physicalize attribute to the materials. /*! /param $materials The materials that need to add physicalize attribute. */ global proc LumberyardAddMaterialPhysicalizeTypes(string $materials[]) { for ($material in $materials) { if (!`attributeExists "physicalise" $material`) { cryExportAddEnumAttribute $material "physicalise" `cryExportGetMaterialPhysicalizeEnumString`; } if (LumberyardIsDefaultProxyNoDraw($material)) { // ProxyNoDraw = 2 setAttr ($material + ".physicalise") 2; } } } //! Remove physicalize attribute from the materials. /*! /param $materials The materials that need to remove physicalize attribute. /note We need to remove the physicalize attribute from material when we remove the material from a group so that in the future, when the material is added again to a group, its physicalize attribute will be recreated and its default value is "None". */ global proc LumberyardRemoveMaterialPhysicalizeTypes(string $materials[]) { for ($material in $materials) { if (`attributeExists "physicalise" $material`) { deleteAttr -attribute "physicalise" $material; } } } //! Set the physicalize attribute of a material from optionMenu selection. /*! /param $groupIndex The index of the material group that the material belongs to. /param $materialIndex The index of the material within the group. */ global proc LumberyardSetMaterialPhysicalizeType(int $groupIndex, int $materialIndex) { string $materialName = `LumberyardToolGetMaterialNameFromItemId $groupIndex $materialIndex`; int $newType = (`optionMenu -query -select (LumberyardGetMaterialItemPhysicalizeOptionMenu($groupIndex, $materialIndex))` - 1); setAttr ($materialName + ".physicalise") $newType; } //! Update the optionMenu selection for the physicalize attribute of a material item. /*! /param $groupIndex The index of the material group that the material belongs to. /param $materialIndex The index of the material within the group. */ global proc LumberyardUpdateMaterialTreeViewItemPhysicalizeType(int $groupIndex, int $materialIndex) { string $materialName = `LumberyardToolGetMaterialNameFromItemId $groupIndex $materialIndex`; if (`attributeExists "physicalise" $materialName`) { int $currentType =(`getAttr ($materialName + ".physicalise")` + 1); optionMenu -edit -select $currentType `LumberyardGetMaterialItemPhysicalizeOptionMenu $groupIndex $materialIndex`; } } // Current number of material groups. global int $g_materialGroupItemCount = 0; // Current number of materials. global int $g_materialItemCount = 0; // All tree view material item rows. global string $g_materialItemRows[]; // Full names of all material rows. This is used for drag and drop operations. global string $g_materialItemRowFullNames[]; // Text fields of all materials. global string $g_materialItemNames[]; // Number of materials in each material group. global int $g_materialInGroupNums[]; //! Update material tree view with the current material group settings. global proc LumberyardToolUpdateMaterialTreeView() { global int $g_materialGroupItemCount; global int $g_materialItemCount; global string $g_materialItemRows[]; global string $g_materialItemRowFullNames[]; global string $g_materialItemNames[]; global int $g_materialInGroupNums[]; global int $g_currentSelectedMaterialGroupId; global string $g_addMaterialButton; // For updating selected item. string $selectedItem = `LumberyardToolMaterialGetSelectedItem`; $g_currentSelectedMaterialGroupId = -1; LumberyardSetSelectedMaterialGlobalId -1 -1; // string $childItems[] = `scrollLayout -query -childArray LUMBERYARDTOOL_MATERIAL_TREEVIEW`; for ($child in $childItems) { deleteUI $child; } string $partitionName = `cryMaterialGetPartitionName`; string $materialGroups[]; if (!`objExists $partitionName`) { // Create a dummy set and add to new partition to avoid script warning. Remove the dummy set right after partition creation. sets -name "dummySet1"; partition -name $partitionName "dummySet1"; partition -removeSet $partitionName "dummySet1"; delete "dummySet1"; } $materialGroups = `partition -query $partitionName`; $g_materialGroupItemCount = `size($materialGroups)`; $g_materialItemCount = 0; if (size($materialGroups) == 0) { LumberyardToolAddMaterialInstructionTexts; return; } int $checkBoxStates[] = `LumberyardToolGetMaterialGroupExportSelections`; for ($i = 0; $i < $g_materialGroupItemCount; $i++) { if (`objExists $materialGroups[$i]`) { setParent LUMBERYARDTOOL_MATERIAL_TREEVIEW; LumberyardToolAddGroupItemToMaterialTreeView $materialGroups[$i] $i $checkBoxStates[$i]; // For updating selected item. if ($selectedItem == $materialGroups[$i]) { $g_currentSelectedMaterialGroupId = $i; LumberyardToolMaterialSetHighLightRow `LumberyardToolGetMaterialGroupItemRow $g_currentSelectedMaterialGroupId`; } // string $contents[] = `cryMaterialGetGroupShaders $materialGroups[$i]`; $g_materialInGroupNums[$i] = size($contents); for ($j = 0; $j < `size($contents)`; $j++) { string $materialName = `cryMaterialUIShaderNameEncode $materialGroups[$i] $contents[$j]`; $materialName = `cryMaterialUIShaderNameDecode $materialName`; $g_materialItemRowFullNames[$g_materialItemCount] = `LumberyardToolAddMaterialItemToMaterialTreeView $materialName $i $j`; // For updating selected item. $g_materialItemRows[$g_materialItemCount] = `LumberyardToolGetMateriaItemRow $i $j`; $g_materialItemNames[$g_materialItemCount] = `LumberyardToolGetMaterialItemName $i $j`; if ($selectedItem == $materialName) { LumberyardSetSelectedMaterialGlobalId $i $g_materialItemCount; LumberyardToolMaterialSetHighLightRow $g_materialItemRows[$g_materialItemCount]; } // $g_materialItemCount++; } } } if ($g_currentSelectedMaterialGroupId == -1) { button -edit -enable false $g_addMaterialButton; } } //! Export checked material groups. /*! /param $showDialogs A flag controls whether to show a confirmation dialogue about how many files are exported. */ global proc LumberyardToolExportCheckedMaterialGroups(int $showDialogs) { global int $g_materialGroupItemCount; string $selectedGroups[]; int $selectedId = 0; for ($i = 0; $i < $g_materialGroupItemCount; $i++) { if (`checkBox -query -value (LumberyardToolGetMaterialGroupItemCheckBoxName($i))`) { string $selectedGroup = `LumberyardToolGetMaterialGroupItemNameValue $i`; if (`objExists $selectedGroup`) { $selectedGroups[$selectedId] = $selectedGroup; $selectedId++; } } } LumberyardToolUpdateMaterialExportPath; string $folderPath = `cryExportGetExportSettingValue "customMaterialFilePath"`; LumberyardExportSelectedMaterials $selectedGroups $folderPath $showDialogs; } //! Set material export path. global proc LumberyardToolUpdateMaterialExportPath() { global string $g_defaultPathString; string $folderPath = `textField -query -text LUMBERYARDTOOL_MATERIALEXPORTPATH_TEXTFIELD`; // For empty path, make sure UI is updated if($folderPath == "") { LumberyardUtilitiesSetTextToDefaultPath("LUMBERYARDTOOL_MATERIALEXPORTPATH_TEXTFIELD"); } // For default path, make sure empty string is passed to data backend else if(`gmatch $folderPath $g_defaultPathString` == 1) { $folderPath = ""; } else { $folderPath = `cryExportFixupPath $folderPath`; textField -edit -text $folderPath LUMBERYARDTOOL_MATERIALEXPORTPATH_TEXTFIELD; } cryExportSetExportSettingValue "customMaterialFilePath" $folderPath; } //! Set material export path by browsing folder. global proc LumberyardToolSetMaterialExportPathFromFileBrowser() { string $result[] = `LumberyardBrowseForPath "" "Set Material Export Path"`; string $folderPath; if (size($result) == 1) { $folderPath = `cryExportFixupPath $result[0]`; textField -edit -text $folderPath LUMBERYARDTOOL_MATERIALEXPORTPATH_TEXTFIELD; LumberyardToolUpdateMaterialExportPath; } } //! Get material export path from saved back-end data. proc string LumberyardToolGetMaterialExportPath() { global string $g_defaultPathString; string $filePath = `cryExportGetExportSettingValue "customMaterialFilePath"`; if($filePath == "") { $filePath = $g_defaultPathString; } return $filePath; } // Selected material group index. global int $g_currentSelectedMaterialGroupId = -1; // Selected material global index by considering materials from all groups. global int $g_currentSelectedMaterialId = -1; // The index of the owner group of the selected material. global int $g_currentSelectedMaterialOwnerGroupId = -1; //! Record the current selected material global index and the index of the material group that owns that material. /*! /param $groupIndex The index of the material group that the material belongs to. /param $materialIndex The index of the material within the group. */ global proc LumberyardSetSelectedMaterialGlobalId(int $groupIndex, int $materialIndex) { global int $g_currentSelectedMaterialId; global int $g_currentSelectedMaterialOwnerGroupId; $g_currentSelectedMaterialId = $materialIndex; $g_currentSelectedMaterialOwnerGroupId = $groupIndex; } //! Highlight specific item row in material tree view. /*! /param $rowName Name of the item row to highlight. */ global proc LumberyardToolMaterialSetHighLightRow(string $rowName) { global float $g_highLightColor[]; rowLayout -edit -backgroundColor $g_highLightColor[0] $g_highLightColor[1] $g_highLightColor[2] $rowName; } //! Record the current selected material group item. /*! /param $groupIndex The material group index. */ global proc LumberyardToolMaterialTreeViewGroupItemOnFocus(int $groupIndex) { global int $g_currentSelectedMaterialGroupId; global int $g_materialGroupItemCount; global int $g_materialItemCount; global string $g_materialItemRows[]; global string $g_addMaterialButton; $g_currentSelectedMaterialGroupId = $groupIndex; LumberyardSetSelectedMaterialGlobalId -1 -1; // Highlight selected material group item. for ($i = 0; $i < $g_materialGroupItemCount; $i++) { if ($i == $groupIndex) { LumberyardToolMaterialSetHighLightRow `LumberyardToolGetMaterialGroupItemRow $i`; } else { rowLayout -edit -backgroundColor 0 0 0 `LumberyardToolGetMaterialGroupItemRow $i`; } } for ($i = 0; $i < $g_materialItemCount; $i++) { rowLayout -edit -backgroundColor 0 0 0 $g_materialItemRows[$i]; } button -edit -enable true $g_addMaterialButton; LumberyardToolUpdateMaterialAdvancedOptionsFrame; } //! Record the current selected material item. /*! /param $groupIndex The index of the material group that the material belongs to. /param $materialIndex The index of the material within the group. */ global proc LumberyardToolMaterialTreeViewMaterialItemOnFocus(int $groupIndex, int $materialIndex) { global int $g_currentSelectedMaterialGroupId; global int $g_materialGroupItemCount; global int $g_materialItemCount; global string $g_materialItemRows[]; global string $g_addMaterialButton; $g_currentSelectedMaterialGroupId = -1; // Highlight selected material item. for ($i = 0; $i < $g_materialGroupItemCount; $i++) { rowLayout -edit -backgroundColor 0 0 0 `LumberyardToolGetMaterialGroupItemRow $i`; } for ($i = 0; $i < $g_materialItemCount; $i++) { if ($g_materialItemRows[$i] == `LumberyardToolGetMateriaItemRow $groupIndex $materialIndex`) { LumberyardToolMaterialSetHighLightRow $g_materialItemRows[$i]; LumberyardSetSelectedMaterialGlobalId $groupIndex $i; } else { rowLayout -edit -backgroundColor 0 0 0 $g_materialItemRows[$i]; } } button -edit -enable false $g_addMaterialButton; LumberyardToolUpdateMaterialAdvancedOptionsFrame; } //! Get the item name on focus from material tree view. global proc string LumberyardToolMaterialGetSelectedItem() { global int $g_currentSelectedMaterialGroupId; global int $g_currentSelectedMaterialId; global string $g_materialItemNames[]; if ($g_currentSelectedMaterialGroupId >= 0) { if (`textField -exists (LumberyardToolGetMaterialGroupItemName($g_currentSelectedMaterialGroupId))`) return `LumberyardToolGetMaterialGroupItemNameValue $g_currentSelectedMaterialGroupId`; } else if ($g_currentSelectedMaterialId >= 0) { if (`textField -exists $g_materialItemNames[$g_currentSelectedMaterialId]`) { return `textField -query -text $g_materialItemNames[$g_currentSelectedMaterialId]`; } } return ""; } //! View the selected material or material group item in Hypershade panel. global proc LumberyardToolOpenSelectedInHyperShade() { global int $g_currentSelectedMaterialGroupId; global int $g_currentSelectedMaterialId; global string $g_materialItemNames[]; if ($g_currentSelectedMaterialGroupId >= 0) { string $currentSelectedMaterialGroupName = `LumberyardToolGetMaterialGroupItemName $g_currentSelectedMaterialGroupId`; string $currentSelectedMaterialGroup = `textField -query -text $currentSelectedMaterialGroupName`; select -replace -noExpand $currentSelectedMaterialGroup; cryMaterialUIOpenHyperShader; } else if ($g_currentSelectedMaterialId >= 0) { string $currentSelectedMaterialName = $g_materialItemNames[$g_currentSelectedMaterialId]; string $currentSelectedMaterial = `textField -query -text $currentSelectedMaterialName`; select $currentSelectedMaterial; cryMaterialUIOpenHyperShader; } else { confirmDialog -title "Material" -message ("No material or material group is selected.") -button "OK"; } } //! Callback function when a material item gets dragged. /*! /param $dragControl The material item row being dragged. /param $x The local x coordinate of the drag material item row. /param $y The local y coordinate of the drag material item row. /param $mods Flag indicating whether CTRL and/or SHIFT keys are pressed. */ global proc string[] materialItemDragCallback(string $dragControl, int $x, int $y, int $mods) { string $ret[]; // Simply return. return $ret; } //! Repopulate the material item list under a material group item. /*! /param $groupIndex the index of the material group. */ global proc LumberyardMaterialUpdateMaterialItemList(int $groupIndex) { string $groupItem = `LumberyardToolGetMaterialGroupItemNameValue $groupIndex`; string $contents[] = `cryMaterialGetGroupShaders $groupItem`; for ($i = 0; $i < size($contents); $i++) { string $materialName = `cryMaterialUIShaderNameEncode $groupItem $contents[$i]`; $materialName = `cryMaterialUIShaderNameDecode $materialName`; textField -edit -text $materialName `LumberyardToolGetMaterialItemName $groupIndex $i`; LumberyardUpdateMaterialTreeViewItemPhysicalizeType $groupIndex $i; } } //! Callback function when a material item gets dropped. /*! /param $dragControl The material item row being dragged. /param $dropControl The material item row being dropped. /param $msgs[] User defined message type. /param $x The local x coordinate of the drop material item row. /param $y The local y coordinate of the drop material item row. /param $type Type of operation: values of 1 == Move, 2 == Copy, 3 == Link. */ global proc materialItemDropCallback(string $dragControl, string $dropControl, string $msgs[], int $x, int $y, int $type) { global string $g_materialItemRowFullNames[]; global string $g_materialItemNames[]; global int $g_materialItemCount; global int $g_materialInGroupNums[]; global int $g_materialGroupItemCount; global int $dragRowId = -1; global int $dropRowId = -1; global int $g_rowItemHeight; // Get the global material index for both drag and drop material items. for ($i = 0; $i < $g_materialItemCount; $i++) { if ($g_materialItemRowFullNames[$i] == $dragControl) { $dragRowId = $i; } if ($g_materialItemRowFullNames[$i] == $dropControl) { $dropRowId = $i; } } if ($dragRowId >= 0 && $dropRowId >= 0 && $dragRowId != $dropRowId) { int $moveGroupId = -1; int $sum = 0; for ($i = 0; $i < $g_materialGroupItemCount; $i++) { $sum += $g_materialInGroupNums[$i]; if ($sum > $dragRowId && $sum > $dropRowId) { $moveGroupId = $i; break; } // If the materials corresponding to the rowLayouts are members of // different groups, do not move the material. else if ($sum > $dragRowId || $sum > $dropRowId) { break; } } if ($moveGroupId >= 0) { int $moveSteps = $dropRowId - $dragRowId; if ($y < ($g_rowItemHeight / 2)) { if ($moveSteps > 0) { $moveSteps -= 1; } } else { if ($moveSteps < 0) { $moveSteps += 1; } } if ($moveSteps != 0) { string $currentGroup = `LumberyardToolGetMaterialGroupItemNameValue $moveGroupId`; string $currentMaterials[]; $currentMaterials[0] = `textField -query -text $g_materialItemNames[$dragRowId]`; if ($moveSteps < 0) { while ($moveSteps < 0) { cryMaterialMoveShadersUp $currentGroup $currentMaterials; $moveSteps++; } } else if ($moveSteps > 0) { while ($moveSteps > 0) { cryMaterialMoveShadersDown $currentGroup $currentMaterials; $moveSteps--; } } LumberyardMaterialUpdateMaterialItemList $moveGroupId; } } } } //! Add a new material under the selected material group. global proc LumberyardAddNewMaterialToGroup() { global int $g_currentSelectedMaterialGroupId; LumberyardToolAddNewMaterial $g_currentSelectedMaterialGroupId; } //! Necessary setup when the Lumberyard Tool is loaded or the scene file is changed. global proc LumberyardMaterialOnLoad() { global int $g_currentSelectedMaterialGroupId; $g_currentSelectedMaterialGroupId = -1; LumberyardToolUpdateMaterialTreeView; textField -edit -text `LumberyardToolGetMaterialExportPath` LUMBERYARDTOOL_MATERIALEXPORTPATH_TEXTFIELD; LumberyardToolEnsureAllCorrectMaterialGroupCustomExportPath; LumberyardToolUpdateMaterialAdvancedOptionsFrame; } //! Update the material advance option frame. global proc LumberyardToolUpdateMaterialAdvancedOptionsFrame() { global int $g_currentSelectedMaterialGroupId; if ($g_currentSelectedMaterialGroupId != -1) { // Display the custom export path of the selected material group item. string $customFilePath = `LumberyardToolGetSelectedMaterialGroupCustomExportPath`; textField -edit -enable true -text $customFilePath LUMBERYARDTOOL_MATERIALCUSTOMPATH_TEXTFIELD; iconTextButton -edit -enable true LUMBERYARDTOOL_MATERIALCUSTOMPATH_BUTTON; string $selectedGroup = `LumberyardToolGetMaterialGroupItemNameValue $g_currentSelectedMaterialGroupId`; connectControl LUMBERYARDTOOL_MATERIALCUSTOMPATH_TEXTFIELD ($selectedGroup + ".customExportPath"); } else { textField -edit -enable false -text "" LUMBERYARDTOOL_MATERIALCUSTOMPATH_TEXTFIELD; iconTextButton -edit -enable false LUMBERYARDTOOL_MATERIALCUSTOMPATH_BUTTON; } } //! Resize Lumberyard Tool window by collapsing or expanding the material frame. /*! \param $collapse Whether collapse or expand the material frame. */ global proc LumberyardMaterialResizeWindow(int $collapse) { global int $g_materialHeightDiff; global int $g_materialAdvanceOptionHeightDiff; int $materialHeightDiff = $g_materialHeightDiff; if (`frameLayout -query -collapse LUMBERYARDTOOL_MATERIALADVANCEDOPTIONS_FRAME`) { $materialHeightDiff = $g_materialHeightDiff - $g_materialAdvanceOptionHeightDiff; } if ($collapse) { $materialHeightDiff = -$materialHeightDiff; } LumberyardToolResizeWindow $materialHeightDiff; } //! Collapse material advance option frame. global proc LumberyardMaterialCollapseAdvanceOptionsFrame() { global int $g_materialAdvanceOptionHeightDiff; if (!`frameLayout -query -collapse LUMBERYARDTOOL_MATERIALADVANCEDOPTIONS_FRAME`) { frameLayout -edit -collapse true LUMBERYARDTOOL_MATERIALADVANCEDOPTIONS_FRAME; LumberyardToolResizeWindow (-$g_materialAdvanceOptionHeightDiff); } } // The add material button. global string $g_addMaterialButton; //! Create material export main frame. global proc LumberyardToolCreateMaterialFrame() { global string $g_addMaterialButton; global int $g_boxWidth; global int $g_buttonSpace; global float $g_UIColor[]; int $buttonWidth = ($g_boxWidth - $g_buttonSpace * 2) / 3; global int $g_materialHeightDiff; global int $g_materialAdvanceOptionHeightDiff; setParent LUMBERYARDTOOL_MAIN_LAYOUT; frameLayout -collapsable true -marginHeight 5 -marginWidth 5 -label "Material Export" -collapseCommand ("LumberyardMaterialResizeWindow " + 1) -expandCommand ("LumberyardMaterialResizeWindow " + 0) LUMBERYARDTOOL_MATERIAL_FRAME; { columnLayout -adjustableColumn true LUMBERYARDTOOL_MATERIAL_LAYOUT; { scrollLayout -height 200 -backgroundColor 0 0 0 -visible true LUMBERYARDTOOL_MATERIAL_TREEVIEW; setParent ..; rowColumnLayout -numberOfRows 1 -width $g_boxWidth -columnSpacing 2 $g_buttonSpace; button -label "Hypershade" -width $buttonWidth -backgroundColor $g_UIColor[0] $g_UIColor[1] $g_UIColor[2] -command ("LumberyardToolOpenSelectedInHyperShade"); button -label "Add Group" -width $buttonWidth -backgroundColor $g_UIColor[0] $g_UIColor[1] $g_UIColor[2] -command ("LumberyardToolAddNewMaterialGroup"); $g_addMaterialButton = `button -label "Add Material" -width $buttonWidth -enable false -backgroundColor $g_UIColor[0] $g_UIColor[1] $g_UIColor[2] -command ("LumberyardAddNewMaterialToGroup")`; setParent ..; rowColumnLayout -numberOfRows 1 -height 30 -rowOffset 1 "both" 4 -columnSpacing 3 $g_buttonSpace; text -label "Export Path" -width 70; textField -text `LumberyardToolGetMaterialExportPath` -width 200 -changeCommand ("LumberyardToolUpdateMaterialExportPath") LUMBERYARDTOOL_MATERIALEXPORTPATH_TEXTFIELD; popupMenu; { menuItem -label "Reset" -command ("LumberyardResetCustomString LUMBERYARDTOOL_MATERIALEXPORTPATH_TEXTFIELD"); } iconTextButton -image "icons/lumberyard_folder_icon.png" -width 20 -height 18 -backgroundColor $g_UIColor[0] $g_UIColor[1] $g_UIColor[2] -command ("LumberyardToolSetMaterialExportPathFromFileBrowser"); // Create Advanced Options frame setParent LUMBERYARDTOOL_MATERIAL_LAYOUT; frameLayout -collapsable true -collapse false -marginHeight 5 -marginWidth 5 -label "Advanced Options" -collapseCommand ("LumberyardToolResizeWindow " + (-$g_materialAdvanceOptionHeightDiff)) -expandCommand ("LumberyardToolResizeWindow " + $g_materialAdvanceOptionHeightDiff) LUMBERYARDTOOL_MATERIALADVANCEDOPTIONS_FRAME; rowColumnLayout -numberOfRows 1 -height 30 -rowOffset 1 "both" 4 -columnSpacing 3 $g_buttonSpace; text -label "Custom Path" -width 70; textField -width 190 -text `LumberyardToolGetSelectedMaterialGroupCustomExportPath` -changeCommand ("LumberyardToolSetMaterialGroupCustomExportPathFromTextField") LUMBERYARDTOOL_MATERIALCUSTOMPATH_TEXTFIELD; iconTextButton -image "icons/lumberyard_folder_icon.png" -width 20 -height 18 -backgroundColor $g_UIColor[0] $g_UIColor[1] $g_UIColor[2] -command ("LumberyardToolSetMaterialGroupCustomExportPathFromBrowser") LUMBERYARDTOOL_MATERIALCUSTOMPATH_BUTTON; LumberyardToolUpdateMaterialAdvancedOptionsFrame; setParent LUMBERYARDTOOL_MATERIAL_LAYOUT; button -label "Export Materials" -backgroundColor $g_UIColor[0] $g_UIColor[1] $g_UIColor[2] -command ("LumberyardToolExportCheckedMaterialGroups 1") LUMBERYARDTOOL_EXPORTMATERIAL_BUTTON; } } LumberyardMaterialOnLoad; scriptJob -event "NewSceneOpened" "LumberyardMaterialOnLoad" -parent "LUMBERYARDTOOL_MAIN_LAYOUT"; scriptJob -event "PostSceneRead" "LumberyardMaterialOnLoad" -parent "LUMBERYARDTOOL_MAIN_LAYOUT"; scriptJob -event "NameChanged" "LumberyardToolUpdateMaterialTreeView" -parent "LUMBERYARDTOOL_MAIN_LAYOUT"; }