// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "Internationalization/Text.h" #include "UObject/GCObject.h" #include "LevelEditorDragDropHandler.generated.h" class FViewport; struct FAssetData; struct FLevelEditorDragDropWorldSurrogateReferencingObject : public FGCObject { public: FLevelEditorDragDropWorldSurrogateReferencingObject(const UObject* InSurrogateObject) { SurrogateObject = InSurrogateObject; } bool IsValid() const { return GetValue() != nullptr; } const UObject* GetValue() const { return SurrogateObject; } virtual bool OnPreDropObjects(UWorld* World, const TArray& DroppedObjects) { return true; } virtual bool OnPostDropObjects(UWorld* World, const TArray& DroppedObjects) { return true; } //~ Begin FGCObject Interface virtual void AddReferencedObjects(FReferenceCollector& Collector) override { Collector.AddReferencedObject(SurrogateObject); } virtual FString GetReferencerName() const override { return TEXT("FLevelEditorDragDropWorldSurrogateReferencingObject"); } //~ End FGCObject Interface protected: TObjectPtr SurrogateObject; }; UCLASS(transient, MinimalAPI) class ULevelEditorDragDropHandler : public UObject { public: GENERATED_BODY() public: UNREALED_API ULevelEditorDragDropHandler(); UNREALED_API virtual bool PreviewDropObjectsAtCoordinates(int32 MouseX, int32 MouseY, UWorld* World, FViewport* Viewport, const FAssetData& AssetData); UNREALED_API virtual bool PreDropObjectsAtCoordinates(int32 MouseX, int32 MouseY, UWorld* World, FViewport* Viewport, const TArray& DroppedObjects, TArray& OutNewActors); UNREALED_API virtual bool PostDropObjectsAtCoordinates(int32 MouseX, int32 MouseY, UWorld* World, FViewport* Viewport, const TArray& DroppedObjects); bool GetCanDrop() const { return bCanDrop; } FText GetPreviewDropHintText() const { return HintText; } DECLARE_DELEGATE_RetVal_TwoParams(TUniquePtr, FOnLevelEditorDragDropWorldSurrogateReferencingObject, UWorld*, const FSoftObjectPath&); FOnLevelEditorDragDropWorldSurrogateReferencingObject& OnLevelEditorDragDropWorldSurrogateReferencingObject() { return OnLevelEditorDragDropWorldSurrogateReferencingObjectDelegate; } protected: bool PassesFilter(UWorld* World, const FAssetData& AssetData, TUniquePtr* OutWorldSurrogateReferencingObject = nullptr); bool bRunAssetFilter = true; /** True if it's valid to drop the object at the location queried */ bool bCanDrop = false; /** Optional hint text that may be returned to the user. */ FText HintText; TUniquePtr WorldSurrogateReferencingObject; FOnLevelEditorDragDropWorldSurrogateReferencingObject OnLevelEditorDragDropWorldSurrogateReferencingObjectDelegate; };