A simple Asset Action Utility to Replace a selection's mesh with a duplicate mesh asset stored in /Game/Modeler folder named 'AssetName_CopiedMesh'
A paste of this into an asset action utility function:
This script assumes a selected static mesh actor (source) and creates a target mesh assset in content browser, then does a Replace of the target mesh into the source mesh. This is good for use with Modeler, so you don't write over existing meshes when making edits for example.
Note: This script doesn't support Undo (it will only undo the last step in the chain of commands it executes).
You need to either create a folder called /Game/Modeler OR in the Asset Action Utility : ReplaceMeshWithMeshCopy modify the DestinationPath string to an existing folder (the default value is /Game/Modeler/ ).
Here's some of the things to be aware of using this asset action:
It tests the destination path is valid.
It tests there is a selection.
It tests that the selection is a Static Mesh.
It tests that there is only one (this script could be elaborated to handle multiple select meshes, but assumes one in this case).
It tests the asset path already exists (path here means the asset itself, not just the folder name).
If the target mesh path already exists, it skips creating the new asset and uses the existing one for doing the Replace command instead.
The first part gets the Selection (as an array) from the viewport.
The second part duplicates the mesh (using its asset path) to the destination path.
Below is shown the collapsed node 'SceneActorAssetPath' on the left of the above pic:
The third part swaps the mesh on the selected actor to use the duplicated asset's mesh. It spawns a mesh to reference then deletes it. In some cases you might want to spawn a mesh and remove the existing source actor.
Note that just replacing the mesh component keeps the source actor transforms (in the current scene).
Comments