You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
First phase of converting Level Editor viewport selection to use typed elements
This phase focuses on the minimum set of changes needed to port the UnrealEd logic for handling the selection of actors and components within the Level Editor viewport to use typed element interfaces. There is still future work to be done to clean this up further. This change adds a new framework type, UTypedElementSelectionSet, which manages the concept of "selection" for typed elements. Internally this owns its own UTypedElementList, and ensures that mutation of that list goes via the UTypedElementSelectionInterface implementations. To allow specific asset editors to customize their selection behavior, UTypedElementSelectionSet may have "selection proxies" that implement UTypedElementAssetEditorSelectionProxy registered to it. This is what's used to allow the level editor to implement its type specific rules. The core Level Editor selection implementation for actors and components now lives inside UActorElementLevelEditorSelectionProxy and UComponentElementLevelEditorSelectionProxy, and the existing UUnrealEdEngine functions that used to deal with this logic now proxy through to those implementations via UTypedElementSelectionSet. This means that the implementation has moved into the LevelEditor module without UnrealEd even knowing. Future work will focus on: - Cleaning up the legacy USelection bridge, so that all USelection instances are just a proxy around a UTypedElementSelectionSet. - This will involve making a basic "Object" element type to handle the generic UObject based selection (for assets) that USelection also handles. - This should allow GetMutableElementList to be removed from UTypedElementSelectionSet, to avoid potential abuse or misuse. - Investigating the best way to integrate element based selection into the editor modes. #rb Chris.Gagnon, Brooke.Hubert #rnx [CL 14470181 by Jamie Dale in ue5-main branch]
This commit is contained in:
@@ -56,9 +56,11 @@
|
||||
#include "StatusBarSubsystem.h"
|
||||
#include "Widgets/Colors/SColorPicker.h"
|
||||
#include "SourceCodeNavigation.h"
|
||||
#include "TypedElementRegistry.h"
|
||||
#include "Editor/EnvironmentLightingViewer/Public/EnvironmentLightingModule.h"
|
||||
#include "Misc/MessageDialog.h"
|
||||
#include "Elements/TypedElementSelectionSet.h"
|
||||
#include "Elements/Actor/ActorElementLevelEditorSelectionProxy.h"
|
||||
#include "Elements/Component/ComponentElementLevelEditorSelectionProxy.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "SLevelEditor"
|
||||
|
||||
@@ -215,12 +217,16 @@ void SLevelEditor::Construct( const SLevelEditor::FArguments& InArgs)
|
||||
|
||||
void SLevelEditor::Initialize( const TSharedRef<SDockTab>& OwnerTab, const TSharedRef<SWindow>& OwnerWindow )
|
||||
{
|
||||
SelectedElements = UTypedElementRegistry::GetInstance()->CreateElementList();
|
||||
SelectedElements = NewObject<UTypedElementSelectionSet>();
|
||||
SelectedElements->AddToRoot();
|
||||
|
||||
// Register the level editor specific selection behavior
|
||||
SelectedElements->RegisterAssetEditorSelectionProxy(NAME_Actor, NewObject<UActorElementLevelEditorSelectionProxy>());
|
||||
SelectedElements->RegisterAssetEditorSelectionProxy(NAME_Components, NewObject<UComponentElementLevelEditorSelectionProxy>());
|
||||
|
||||
// Allow USelection to bridge to our selected element list
|
||||
GUnrealEd->GetSelectedActors()->SetElementList(SelectedElements);
|
||||
GUnrealEd->GetSelectedComponents()->SetElementList(SelectedElements);
|
||||
GUnrealEd->GetSelectedActors()->SetElementSelectionSet(SelectedElements);
|
||||
GUnrealEd->GetSelectedComponents()->SetElementSelectionSet(SelectedElements);
|
||||
|
||||
// Bind the level editor tab's label to the currently loaded level name string in the main frame
|
||||
OwnerTab->SetLabel( TAttribute<FText>( this, &SLevelEditor::GetTabTitle) );
|
||||
@@ -329,12 +335,12 @@ SLevelEditor::~SLevelEditor()
|
||||
// Clear USelection from using our selected element list
|
||||
if (GUnrealEd)
|
||||
{
|
||||
GUnrealEd->GetSelectedActors()->SetElementList(nullptr);
|
||||
GUnrealEd->GetSelectedComponents()->SetElementList(nullptr);
|
||||
GUnrealEd->GetSelectedActors()->SetElementSelectionSet(nullptr);
|
||||
GUnrealEd->GetSelectedComponents()->SetElementSelectionSet(nullptr);
|
||||
}
|
||||
if (UObjectInitialized())
|
||||
{
|
||||
SelectedElements->Empty();
|
||||
SelectedElements->ClearSelection(FTypedElementSelectionOptions());
|
||||
SelectedElements->RemoveFromRoot();
|
||||
SelectedElements = nullptr;
|
||||
}
|
||||
@@ -1612,6 +1618,16 @@ void SLevelEditor::OnLayoutHasChanged()
|
||||
// ...
|
||||
}
|
||||
|
||||
const UTypedElementSelectionSet* SLevelEditor::GetElementSelectionSet() const
|
||||
{
|
||||
return SelectedElements;
|
||||
}
|
||||
|
||||
UTypedElementSelectionSet* SLevelEditor::GetMutableElementSelectionSet()
|
||||
{
|
||||
return SelectedElements;
|
||||
}
|
||||
|
||||
void SLevelEditor::SummonLevelViewportContextMenu(AActor* HitProxyActor)
|
||||
{
|
||||
FLevelEditorContextMenu::SummonMenu( SharedThis( this ), ELevelEditorMenuContext::Viewport, HitProxyActor);
|
||||
|
||||
Reference in New Issue
Block a user