Prevent Actor editing

Hi,

we are currently writing a custom editor mode that spawns actors from code and we would like do restrict editing those actors. In particular we want to…

  • prevent an actor from being transformed
  • prevent an actor from getting deleted manually by the user
  • prevent an actor from being listed in the editor’s World Outliner

I found the UObject::CanEditChange(const UProperty* InProperty) function which seemed to be promising for the first restriction, but actually I don’t get transformation changes there. And for the second and third points I didn’t find anything either.

Is there a way to achieve these things?

EDIT: I now also tried to replace the RootComponent with a custom class where I overwrite the property change functions, but the same as before: no transformation changes are recognized there. The only idea I have for the transformation part is to store the actor location and restore it in PostEditMove() to the value that was stored. But that is not the ideal.

Thanks,
Anselm

There is set of virtual function that allows to override or extend editor editing behavior of specific actor:

Translation = Moving object

By overrideing one of those without Super call, it will block it’s function.

There some other useful function, look up API refrence

Remeber also that this is editor only code and so you need to place bioth function decleres and function defines (actual function code) inside:

#if WITH_EDITOR
...
#endif

So that portion of the code will only compile in editor builds, if you don’t to that you will have compile errors in packageing

Also if you want to lookup original code of those functions they are here, editor code for Actor class is in sperate file:

https://github.com/EpicGames/UnrealEngine/blob/edb65ee72ed06ba829792e7bd3f641ee8c78dd36/Engine/Source/Runtime/Engine/Private/ActorEditor.cpp#L446

Really interesting ! Thank you !

Oh, I didn’t notice that those EditorApply* functions are part of the actor class. That helps at least for the transformation part. Thanks a lot! :smiley:

Ah you want 2 other things

There bListedInSceneOutliner it’s protected varbale so you can only change it inside actor related class, in other words you can change it outside the object.

As for prevent destroying, i dont think there a way to change that other then modifying editor tools, there EditorDestroyActor but thats part of UWorld (same as SpawnActor) I can point you to where is editor delete code, you might try to investigate it

https://github.com/EpicGames/UnrealEngine/blob/11c468d5b3e1cecb80991ae15328994580b83bd1/Engine/Source/Editor/UnrealEd/Private/ObjectTools.cpp#L1885

Strange, I looked through the actor members last week and saw bHiddenEd, bEditable and several bHiddenEd* members but managed to miss the bListedInSceneOutliner that is defined right in the middle of them.

Works like a charm. Thanks again. :slight_smile:

I just saw that there is also a public bLockLocation member that locks the actor’s entire transformation (translation, scale & rotation) which might come in handy if you can’t override the EditorApply* functions.

so great,helps me out .thx