You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
This represents UE4/Main @18073326, Release-5.0 @18081140 and Dev-PerfTest @18045971 [CL 18081471 by aurel cordonnier in ue5-release-engine-test branch]
51 lines
1.3 KiB
C++
51 lines
1.3 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "ScopedTransaction.h"
|
|
#include "WorldPartition/WorldPartition.h"
|
|
#include "Engine/World.h"
|
|
#include "Editor.h"
|
|
|
|
class FScopedDataLayerTransaction
|
|
{
|
|
public:
|
|
FScopedDataLayerTransaction(const FText& SessionName, UWorld* InWorld)
|
|
: WorldPtr(InWorld)
|
|
, bUndoTransaction(false)
|
|
{
|
|
check(InWorld);
|
|
ScopedTransaction = new FScopedTransaction(SessionName);
|
|
UWorldPartition* WorldPartition = InWorld->GetWorldPartition();
|
|
WorldPartition->OnCancelWorldPartitionUpdateEditorCells.AddRaw(this, &FScopedDataLayerTransaction::OnCancelUpdateEditorCells);
|
|
}
|
|
|
|
~FScopedDataLayerTransaction()
|
|
{
|
|
UWorld* World = WorldPtr.Get();
|
|
if (UWorldPartition* WorldPartition = World ? World->GetWorldPartition() : nullptr)
|
|
{
|
|
WorldPartition->OnCancelWorldPartitionUpdateEditorCells.RemoveAll(this);
|
|
}
|
|
delete ScopedTransaction;
|
|
if (bUndoTransaction)
|
|
{
|
|
GEditor->UndoTransaction();
|
|
}
|
|
}
|
|
|
|
private:
|
|
|
|
void OnCancelUpdateEditorCells(UWorldPartition* InWorldPartition)
|
|
{
|
|
UWorld* World = WorldPtr.Get();
|
|
if (World && (World->GetWorldPartition() == InWorldPartition))
|
|
{
|
|
bUndoTransaction = true;
|
|
}
|
|
}
|
|
|
|
FScopedTransaction* ScopedTransaction;
|
|
TWeakObjectPtr<UWorld> WorldPtr;
|
|
bool bUndoTransaction;
|
|
}; |