mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
Fixes Datablock and Prefab DragnDrop behavior with the AB
This commit is contained in:
parent
80eb4ab2ba
commit
a43abffed2
3 changed files with 58 additions and 4 deletions
|
|
@ -2234,6 +2234,10 @@ function EWorldEditor::onControlDropped( %this, %payload, %position )
|
||||||
{
|
{
|
||||||
%buildCommand = AssetBrowser @ ".on" @ %assetType @ "EditorDropped(" @ %asset @ ",\"" @ %position @ "\");";
|
%buildCommand = AssetBrowser @ ".on" @ %assetType @ "EditorDropped(" @ %asset @ ",\"" @ %position @ "\");";
|
||||||
}
|
}
|
||||||
|
else if(%assetType $= "Prefab")
|
||||||
|
{
|
||||||
|
%buildCommand = AssetBrowser @ ".on" @ %assetType @ "EditorDropped(\"" @ %module @ "/" @ %asset @ "\",\"" @ %position @ "\");";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
%assetDef = AssetDatabase.acquireAsset(%module @ ":" @ %asset);
|
%assetDef = AssetDatabase.acquireAsset(%module @ ":" @ %asset);
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ function AssetBrowser::buildDatablockPreview(%this, %assetDef, %previewData)
|
||||||
//%previewData.assetFriendlyName = %assetDef.assetName;
|
//%previewData.assetFriendlyName = %assetDef.assetName;
|
||||||
%previewData.assetDesc = %assetDef;
|
%previewData.assetDesc = %assetDef;
|
||||||
%previewData.tooltip = %assetDef;
|
%previewData.tooltip = %assetDef;
|
||||||
%previewData.doubleClickCommand = "DatablockEditorPlugin.openDatablock(" @ %assetDef @ ");";
|
%previewData.doubleClickCommand = "AssetBrowser.schedule(10, \"spawnDatablockObject\",\""@ %assetDef @"\");";//browseTo %assetDef.dirPath / %assetDef.assetName
|
||||||
}
|
}
|
||||||
|
|
||||||
function spawnDatablockObject(%datablock)
|
function spawnDatablockObject(%datablock)
|
||||||
|
|
@ -59,9 +59,9 @@ function spawnDatablockObject(%datablock)
|
||||||
%class = %datablock.getClassName();
|
%class = %datablock.getClassName();
|
||||||
%cmd = %class @ "::create(" @ %name @ ");";
|
%cmd = %class @ "::create(" @ %name @ ");";
|
||||||
|
|
||||||
%shapePath = ( %datablock.shapeFile !$= "" ) ? %datablock.shapeFile : %datablock.shapeName;
|
%shapePath = ( %datablock.shapeAsset !$= "" ) ? %datablock.shapeFile : %datablock.shapeName;
|
||||||
%createCmd = "EWCreatorWindow.createObject( \"" @ %cmd @ "\" );";
|
%createCmd = "EWCreatorWindow.createObject( \"" @ %cmd @ "\" );";
|
||||||
return eval(%createCmd);
|
return eval(%createCmd);//eval("showImportDialog( \"" @ %shapePath @ "\", \"" @ %createCmd @ "\" );");
|
||||||
}
|
}
|
||||||
|
|
||||||
function AssetBrowser::renameDatablock(%this, %folderPath, %newFolderName)
|
function AssetBrowser::renameDatablock(%this, %folderPath, %newFolderName)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,20 @@
|
||||||
|
function AssetBrowser::createPrefab(%this)
|
||||||
|
{
|
||||||
|
%moduleName = AssetBrowser.newAssetSettings.moduleName;
|
||||||
|
%modulePath = "data/" @ %moduleName;
|
||||||
|
|
||||||
|
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||||
|
|
||||||
|
%assetPath = AssetBrowser.dirHandler.currentAddress @ "/";
|
||||||
|
|
||||||
|
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
|
||||||
|
%prefabFilePath = %assetPath @ %assetName @ ".prefab";
|
||||||
|
|
||||||
|
EWorldEditor.makeSelectionPrefab( %prefabFilePath );
|
||||||
|
|
||||||
|
EditorTree.buildVisibleTree( true );
|
||||||
|
}
|
||||||
|
|
||||||
function AssetBrowser::buildPrefabPreview(%this, %assetDef, %previewData)
|
function AssetBrowser::buildPrefabPreview(%this, %assetDef, %previewData)
|
||||||
{
|
{
|
||||||
%fullPath = %assetDef.dirPath @ "/" @ %assetDef.assetName;
|
%fullPath = %assetDef.dirPath @ "/" @ %assetDef.assetName;
|
||||||
|
|
@ -12,3 +29,36 @@ function AssetBrowser::buildPrefabPreview(%this, %assetDef, %previewData)
|
||||||
//%previewData.doubleClickCommand = "AssetBrowser.schedule(10, \"navigateTo\",\""@ %assetDef.dirPath @ "/" @ %assetDef.assetName @"\");";//browseTo %assetDef.dirPath / %assetDef.assetName
|
//%previewData.doubleClickCommand = "AssetBrowser.schedule(10, \"navigateTo\",\""@ %assetDef.dirPath @ "/" @ %assetDef.assetName @"\");";//browseTo %assetDef.dirPath / %assetDef.assetName
|
||||||
%previewData.doubleClickCommand = "AssetBrowser.autoImportFile(\"" @ %fullPath @ "\");";
|
%previewData.doubleClickCommand = "AssetBrowser.autoImportFile(\"" @ %fullPath @ "\");";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function AssetBrowser::onPrefabEditorDropped(%this, %assetDef, %position)
|
||||||
|
{
|
||||||
|
//echo("DROPPED A SHAPE ON THE EDITOR WINDOW!");
|
||||||
|
|
||||||
|
%targetPosition = EWorldEditor.unproject(%position SPC 1000);
|
||||||
|
%camPos = LocalClientConnection.camera.getPosition();
|
||||||
|
%rayResult = containerRayCast(%camPos, %targetPosition, -1);
|
||||||
|
|
||||||
|
%pos = EWCreatorWindow.getCreateObjectPosition();
|
||||||
|
|
||||||
|
if(%rayResult != 0)
|
||||||
|
{
|
||||||
|
%pos = getWords(%rayResult, 1, 3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
%pos = "0 0 0";
|
||||||
|
}
|
||||||
|
|
||||||
|
%newPrefab = new Prefab()
|
||||||
|
{
|
||||||
|
position = %pos;
|
||||||
|
fileName = %assetDef;
|
||||||
|
};
|
||||||
|
|
||||||
|
getScene(0).add(%newPrefab);
|
||||||
|
|
||||||
|
EWorldEditor.clearSelection();
|
||||||
|
EWorldEditor.selectObject(%newPrefab);
|
||||||
|
|
||||||
|
EWorldEditor.isDirty = true;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue