diff --git a/Templates/BaseGame/game/tools/shapeEditor/main.cs b/Templates/BaseGame/game/tools/shapeEditor/main.cs index 721313e95..efbc1c538 100644 --- a/Templates/BaseGame/game/tools/shapeEditor/main.cs +++ b/Templates/BaseGame/game/tools/shapeEditor/main.cs @@ -145,6 +145,13 @@ function ShapeEditorPlugin::onWorldEditorStartup(%this) } } +function ShapeEditorPlugin::openShapeAsset(%this, %assetId) +{ + %this.selectedAssetId = %assetId; + %this.selectedAssetDef = AssetDatabase.acquireAsset(%assetId); + %this.open(%this.selectedAssetDef.fileName); +} + function ShapeEditorPlugin::open(%this, %filename) { if ( !%this.isActivated ) diff --git a/Templates/BaseGame/game/tools/shapeEditor/scripts/shapeEditor.ed.cs b/Templates/BaseGame/game/tools/shapeEditor/scripts/shapeEditor.ed.cs index d79923776..9675ac7c9 100644 --- a/Templates/BaseGame/game/tools/shapeEditor/scripts/shapeEditor.ed.cs +++ b/Templates/BaseGame/game/tools/shapeEditor/scripts/shapeEditor.ed.cs @@ -611,6 +611,19 @@ function ShapeEdPropWindow::update_onShapeSelectionChanged( %this ) ShapeEdSequenceList.addItem( %name ); } ShapeEdThreadWindow.onAddThread(); // add thread 0 + + //Now, fetch any animation assets if we're utilizing a shape asset + if(ShapeEditorPlugin.selectedAssetId !$= "") + { + %animationAssetCount = ShapeEditorPlugin.selectedAssetDef.getAnimationCount(); + + for(%animIdx = 0; %animIdx < %animationAssetCount; %animIdx++) + { + %animAsset = ShapeEditorPlugin.selectedAssetDef.getAnimation(%animIdx); + + //ShapeEdSequenceList.addItem( %animAsset.assetName ); + } + } // --- DETAILS TAB --- // Add detail levels and meshes to tree @@ -789,7 +802,8 @@ function ShapeEdSeqNodeTabBook::onTabSelected( %this, %name, %index ) { case "Seq": ShapeEdPropWindow-->newBtn.ToolTip = "Add new sequence"; - ShapeEdPropWindow-->newBtn.Command = "ShapeEdSequences.onAddSequence();"; + //ShapeEdPropWindow-->newBtn.Command = "ShapeEdSequences.onAddSequence();"; + ShapeEdPropWindow-->newBtn.Command = "AssetBrowser.showDialog(\"ShapeAnimationAsset\", \"onAddAnimationAssetShapeEditor\", \"\", \"\", \"\");"; ShapeEdPropWindow-->newBtn.setActive( true ); ShapeEdPropWindow-->deleteBtn.ToolTip = "Delete selected sequence (cannot be undone)"; ShapeEdPropWindow-->deleteBtn.Command = "ShapeEdSequences.onDeleteSequence();"; diff --git a/Templates/BaseGame/game/tools/shapeEditor/scripts/shapeEditorActions.ed.cs b/Templates/BaseGame/game/tools/shapeEditor/scripts/shapeEditorActions.ed.cs index 2c48b25a1..3847226f6 100644 --- a/Templates/BaseGame/game/tools/shapeEditor/scripts/shapeEditorActions.ed.cs +++ b/Templates/BaseGame/game/tools/shapeEditor/scripts/shapeEditorActions.ed.cs @@ -299,6 +299,12 @@ function ActionEditNodeTransform::undo( %this ) //------------------------------------------------------------------------------ // Add sequence +function onAddAnimationAssetShapeEditor(%selectedAnimation) +{ + echo("SELECTED MUH ASSET"); + ShapeEditor.doAddSequence(%selectedAnimation, 0, 0, 0); +} + function ShapeEditor::doAddSequence( %this, %seqName, %from, %start, %end ) { %action = %this.createAction( ActionAddSequence, "Add sequence" ); @@ -313,23 +319,44 @@ function ShapeEditor::doAddSequence( %this, %seqName, %from, %start, %end ) function ActionAddSequence::doit( %this ) { - // If adding this sequence from an existing sequence, make a backup copy of - // the existing sequence first, so we can edit the start/end frames later - // without having to worry if the original source sequence has changed. - if ( ShapeEditor.shape.getSequenceIndex( %this.from ) >= 0 ) + if(ShapeEditorPlugin.selectedAssetId $= "") { - %this.from = ShapeEditor.getUniqueName( "sequence", "__backup__" @ %this.origFrom @ "_" ); - ShapeEditor.shape.addSequence( %this.origFrom, %this.from ); + // If adding this sequence from an existing sequence, make a backup copy of + // the existing sequence first, so we can edit the start/end frames later + // without having to worry if the original source sequence has changed. + if ( ShapeEditor.shape.getSequenceIndex( %this.from ) >= 0 ) + { + %this.from = ShapeEditor.getUniqueName( "sequence", "__backup__" @ %this.origFrom @ "_" ); + ShapeEditor.shape.addSequence( %this.origFrom, %this.from ); + } + + // Add the sequence + $collada::forceLoadDAE = EditorSettings.value( "forceLoadDAE" ); + %success = ShapeEditor.shape.addSequence( %this.from, %this.seqName, %this.start, %this.end ); + $collada::forceLoadDAE = false; + + if ( %success ) + { + ShapeEdPropWindow.update_onSequenceAdded( %this.seqName, -1 ); + return true; + } } - - // Add the sequence - $collada::forceLoadDAE = EditorSettings.value( "forceLoadDAE" ); - %success = ShapeEditor.shape.addSequence( %this.from, %this.seqName, %this.start, %this.end ); - $collada::forceLoadDAE = false; - - if ( %success ) + else { - ShapeEdPropWindow.update_onSequenceAdded( %this.seqName, -1 ); + %assetDef = AssetDatabase.acquireAsset(%this.seqName); + %moduleName = getWord(getToken(%this.seqName, ":", 0),0); + + %idx = ShapeEdSequenceList.rowCount(); + + %matSet = "ShapeEditorPlugin.selectedAssetDef.animationSequence"@%idx@"=\"@Asset="@%moduleName@":"@%this.seqName.assetName@"\";"; + eval(%matSet); + + %assetPath = AssetDatabase.getAssetFilePath(ShapeEditorPlugin.selectedAssetId); + + %assetImportSuccessful = TAMLWrite(ShapeEditorPlugin.selectedAssetDef, %assetPath); + + AssetDatabase.refreshAsset(ShapeEditorPlugin.selectedAssetId); + return true; } return false;