x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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

Product Version: UE 4.9
Tags:
more ▼

asked Nov 18 '15 at 05:40 PM in C++ Programming

avatar image

AnselmK
11 4 4 8

avatar image frikezhao Dec 07 '17 at 01:43 PM

so great,helps me out .thx

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AActor/EditorApplyMirror/index.html https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AActor/EditorApplyRotation/index.html https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AActor/EditorApplyScale/index.html https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AActor/EditorApplyTranslation/index.html Translation = Moving object https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AActor/EditorCanAttachTo/index.html https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AActor/EditorKeyPressed/index.html https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AActor/EditorReplacedActor/index.html

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

There some other useful function, look up API refrence https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AActor/index.html

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

more ▼

answered Nov 26 '15 at 05:52 PM

avatar image

Shadowriver ♦
26.5k 894 130 1035

avatar image Begounet Nov 26 '15 at 06:47 PM

Really interesting ! Thank you !

avatar image AnselmK Nov 27 '15 at 10:23 AM

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! :D

avatar image Shadowriver ♦ Nov 28 '15 at 02:51 AM

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

avatar image AnselmK Nov 30 '15 at 10:30 AM

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. :)

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question