NegInfinity / ProjectExodus

Project Exodus - Unity to Unreal scene/project transfer tool.
BSD 3-Clause "New" or "Revised" License
491 stars 97 forks source link

Undo doesn't work on imported Actors (from prefabs) #57

Closed DeepVoodooGitHub closed 2 years ago

DeepVoodooGitHub commented 2 years ago

Hi, I've exported a level from Unity to UE4 - all the prefab's are converted to Actors with a SceneComponent (as root) and all the prefab parts as subcomponents.. This all works great

However, I can't actually undo any changes to the actor.. For example; if I move the actor and then "undo" I get the message "Undo: Move Actors" but the actor stays in the same place..

Any ideas, or pointers on why this may be happening?

DeepVoodooGitHub commented 2 years ago

After some debugging it appears that the actors don't have "RF_Transactional" flag set on them, meaning the Undo system throws away any changes after the mouse is released.

DeepVoodooGitHub commented 2 years ago

Should anyone come across this next time; I ended up having to make an ActorActionUtility that iterated all selected objects in the level, then I ran a small bit of C++ (via C++ BP function, see below) that changed the root and root (a SceneComponent) to be RF_Transactional.

Essentially you select all the bad actors that won't undo and then run the editor function to "set" their flags correctly; then you need to "change" something (I added a cube) for the editor to see the map as changed, then save the map - it then persists and undo's work correctly.

UFUNCTION(BlueprintCallable)
    static void SetTransactionalFlag(AActor* OwnerActor)
{
    OwnerActor->SetFlags(RF_Transactional);
    OwnerActor->GetRootComponent()->SetMobility(EComponentMobility::Movable);
    OwnerActor->GetRootComponent()->SetFlags(RF_Transactional);
}