DUPLICATE

DUPLICATE

#Overview

name: DUPLICATE

This variable is created as a Console Variable (cvar).

It is referenced in 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of DUPLICATE is to create a copy of the currently selected object(s) in the Unreal Engine editor. This command is primarily used in the level editing and object manipulation systems.

DUPLICATE is utilized by several Unreal Engine subsystems and modules, including:

  1. The Level Editor module
  2. The Scene Outliner
  3. The Object Mixer plugin
  4. The VR Editor

The value of this variable is not set directly, as it is a command rather than a variable. It is invoked through various user interface actions and command executions.

DUPLICATE interacts with other editor commands and actions, such as DELETE, PASTE, and RENAME. It is often grouped with these actions in context menus and command mappings.

Developers should be aware that:

  1. The DUPLICATE command is context-sensitive and may behave differently depending on the current editing mode or selected objects.
  2. It relies on the GUnrealEd global editor instance to execute the command.
  3. The command’s availability is often determined by a CanExecute function, which checks if duplication is possible in the current context.

Best practices when using this variable include:

  1. Ensuring proper selection of objects before invoking the DUPLICATE command.
  2. Implementing appropriate CanExecute checks to disable the command when it’s not applicable.
  3. Considering any custom logic needed for special object types when implementing duplication functionality.
  4. Being mindful of performance implications when duplicating large or complex objects.
  5. Properly handling any references or dependencies that may be affected by object duplication.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Plugins/Editor/ObjectMixer/ObjectMixer/Source/ObjectMixer/Private/Views/List/Modes/ObjectMixerOutlinerMode.cpp:3174

Scope (from outer to inner):

file
function     void FObjectMixerOutlinerMode::OnDuplicateSelected

Source code excerpt:

void FObjectMixerOutlinerMode::OnDuplicateSelected()
{
	GUnrealEd->Exec(RepresentingWorld.Get(), TEXT("DUPLICATE"));
}

void FObjectMixerOutlinerMode::OnEditCutActorsBegin()
{
	// Only a callback in actor browsing mode
	SceneOutliner->CopyFoldersBegin();

#Loc: <Workspace>/Engine/Plugins/Editor/ObjectMixer/ObjectMixer/Source/ObjectMixer/Private/Views/List/ObjectMixerEditorList.cpp:40

Scope (from outer to inner):

file
function     void FObjectMixerEditorList::RegisterAndMapContextMenuCommands

Source code excerpt:

	);
	ObjectMixerElementEditCommands->MapAction(FGenericCommands::Get().Duplicate,
		FExecuteAction::CreateStatic( &FLevelEditorActionCallbacks::ExecuteExecCommand, FString( TEXT("DUPLICATE") ) ),
		FCanExecuteAction::CreateStatic( &FLevelEditorActionCallbacks::Duplicate_CanExecute )
	);
	ObjectMixerElementEditCommands->MapAction(FGenericCommands::Get().Delete,
		FExecuteAction::CreateStatic( &FLevelEditorActionCallbacks::ExecuteExecCommand, FString( TEXT("DELETE") ) ),
		FCanExecuteAction::CreateStatic( &FLevelEditorActionCallbacks::Delete_CanExecute )
	);
	ObjectMixerElementEditCommands->MapAction(FGenericCommands::Get().Rename,
		FUIAction(FExecuteAction::CreateRaw(this, &FObjectMixerEditorList::OnRenameCommand))
	);

#Loc: <Workspace>/Engine/Source/Editor/LevelEditor/Private/LevelEditor.cpp:779

Scope (from outer to inner):

file
function     void FLevelEditorModule::BindGlobalLevelEditorCommands

Source code excerpt:

	ActionList.MapAction( 
		FGenericCommands::Get().Duplicate, 
		FExecuteAction::CreateStatic( &FLevelEditorActionCallbacks::ExecuteExecCommand, FString( TEXT("DUPLICATE") ) ),
		FCanExecuteAction::CreateStatic( &FLevelEditorActionCallbacks::Duplicate_CanExecute )
		);

	ActionList.MapAction( 
		FGenericCommands::Get().Delete, 
		FExecuteAction::CreateStatic( &FLevelEditorActionCallbacks::ExecuteExecCommand, FString( TEXT("DELETE") ) ),
		FCanExecuteAction::CreateStatic( &FLevelEditorActionCallbacks::Delete_CanExecute )
		);

	ActionList.MapAction( 

#Loc: <Workspace>/Engine/Source/Editor/SceneOutliner/Private/ActorBrowsingMode.cpp:1802

Scope (from outer to inner):

file
function     void FActorBrowsingMode::OnDuplicateSelected

Source code excerpt:

void FActorBrowsingMode::OnDuplicateSelected()
{
	GUnrealEd->Exec(RepresentingWorld.Get(), TEXT("DUPLICATE"));
}

void FActorBrowsingMode::OnEditCutActorsBegin()
{
	// Only a callback in actor browsing mode
	SceneOutliner->CopyFoldersBegin();

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorServer.cpp:5642

Scope: file

Source code excerpt:

	// DUPLICATE: Rerouted to mode-specific command
	//
	else if (FParse::Command(&Str,TEXT("DUPLICATE")))
	{
		return Exec( InWorld, TEXT("ACTOR DUPLICATE") );
	}
	//------------------------------------------------------------------------------------
	// POLY: Polygon adjustment and mapping
	//

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/UnrealEdSrv.cpp:2776

Scope: file

Source code excerpt:

		return true;
	}
	else if( FParse::Command(&Str,TEXT("DUPLICATE")) )
	{
		if (GCurrentLevelEditingViewportClient)
		{
			if (TSharedPtr<ILevelEditor> LevelEditor = GCurrentLevelEditingViewportClient->ParentLevelEditor.Pin())
			{
				if (UTypedElementCommonActions* CommonActions = LevelEditor->GetCommonActions())

#Loc: <Workspace>/Engine/Source/Editor/VREditor/Private/UI/VRRadialMenuHandler.cpp:478

Scope (from outer to inner):

file
function     void UVRRadialMenuHandler::EditMenuGenerator

Source code excerpt:

		FUIAction
		(
			FExecuteAction::CreateStatic(&FLevelEditorActionCallbacks::ExecuteExecCommand, FString(TEXT("DUPLICATE"))),
			FCanExecuteAction::CreateStatic(&FLevelEditorActionCallbacks::Duplicate_CanExecute)
		)
	);
	MenuBuilder.AddMenuEntry(
		LOCTEXT("Paste", "Paste"),
		FText(),
		FSlateIcon(FVREditorStyle::GetStyleSetName(), "VREditorStyle.Paste"),
		FUIAction
		(
			FExecuteAction::CreateStatic(&FLevelEditorActionCallbacks::ExecuteExecCommand, FString(TEXT("EDIT PASTE"))),
			FCanExecuteAction::CreateStatic(&FLevelEditorActionCallbacks::Paste_CanExecute)
		)
	);

	MenuBuilder.AddMenuEntry(