Merge pull request #1493 from Areloch/MakeSelectedAMeshFix

Corrects handling for creating new folders via asset/AB workflow
This commit is contained in:
Brian Roberts 2025-06-03 15:48:09 -05:00 committed by GitHub
commit b4ca6c6e88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 90 additions and 0 deletions

View file

@ -1,5 +1,62 @@
AssetBrowser::registerFileType("FolderObjectType", "Folder", "/", false);
function AssetBrowser::createNewFolder(%this)
{
AssetBrowser_newFolderNameTxt.text = "NewFolder";
Canvas.pushDialog(AssetBrowser_newFolder, 99, true);
AssetBrowser_newFolderNameTxt.selectAllText();
}
function AssetBrowser::doCreateNewFolder(%this)
{
%newFolderName = AssetBrowser_newFolderNameTxt.getText();
if(%newFolderName $= "")
%newFolderName = "NewFolder";
if(SelectAssetPath.isAwake())
{
%currentAddressPath = SelectAssetPath-->folderTree.getItemValue(SelectAssetPath.selectedTreeItem) @ "/" @ SelectAssetPath-->folderTree.getItemText(SelectAssetPath.selectedTreeItem);
}
else
{
%currentAddressPath = AssetBrowser.dirHandler.currentAddress;
}
%newFolderIdx = "";
%matched = true;
%newFolderPath = "";
while(%matched == true)
{
%newFolderPath = %currentAddressPath @ "/" @ %newFolderName @ %newFolderIdx;
if(!isDirectory(%newFolderPath))
{
%matched = false;
}
else
{
%newFolderIdx++;
}
}
//make a dummy file
%file = new FileObject();
%file.openForWrite(%newFolderPath @ "/test");
%file.close();
fileDelete(%newFolderPath @ "/test");
//refresh the directory
AssetBrowser.loadDirectories();
%this.navigateTo(%newFolderPath);
//On the off chance we're trying to select a path, we'll update the select path window too
if(SelectAssetPath.isAwake())
SelectAssetPath.showDialog(%newFolderPath, SelectAssetPath.callback);
}
function FolderObjectType::setupCreateNew()
{
AssetBrowser_newFolderNameTxt.text = "NewFolder";

View file

@ -1,5 +1,38 @@
AssetBrowser::registerAssetType("ShapeAsset", "Shapes");
function ShapeAsset::onCreateNew()
{
%moduleName = $CurrentAssetBrowser.newAssetSettings.moduleName;
%modulePath = "data/" @ %moduleName;
%assetName = $CurrentAssetBrowser.newAssetSettings.assetName;
%assetPath = NewAssetTargetAddress.getText() @ "/";
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
%shapeFilePath = %assetPath @ %assetName @ ".dae";
%asset = new ShapeAsset()
{
AssetName = %assetName;
versionId = 1;
friendlyName = $CurrentAssetBrowser.newAssetSettings.friendlyName;
description = $CurrentAssetBrowser.newAssetSettings.description;
fileName = %assetName @ ".dae";
};
TamlWrite(%asset, %tamlpath);
Canvas.popDialog(AssetBrowser_newComponentAsset);
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
$CurrentAssetBrowser.refresh();
return %tamlpath;
}
function ShapeAsset::onEdit(%this)
{
if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset")