Usage EditCondition in UPROPERTY

Dear,

While working on level editor, I saw some threads and questions about EditCondition meta specifier.
But All examples show use of a single boolean variable as below.

UPROPERTY(EditAnywhere, Category = Game, meta = (EditCondition = "bCanIUse"))

Can I use multiple boolean variables for checking condition with boolean operation?

Thanks in advance.

EditCondition is essentially a shortcut for doing just a very basic check, there is no flexibility. If you need any more control, you need to look into detail customization. There is an excellent intro here. It’s a touch outdated, but there are heaps of up to date examples of use in the engine code, just search for occurrences of IDetailLayoutBuilder.

It’s a fair bit more involved, but once you get the hang of it it’s pretty straightforward and gives you complete control. Essentially what you want to do in this case is call AddProperty() on your category, and then on the returned reference call Visibility() and pass in a delegate in which you can put whatever code you like to determine if your property should be shown. Again, the engine code is full of examples doing precisely this.

Thanks. I tried through your link, but compile error occurs in IDetailCategoryBuilder. I solved my problem by grouping variables with struct so that two editCondition is applied. If there is on the fly documents and convenient way to customize detail panel, that would be very helpful to make fully utilized editor for every games.

Okay glad you got something working. If you need to do anything more complex then the details customization is definitely the way to go. I guess maybe the error you encountered is because the GetProperty() method has now been moved I think, from IDetailCategoryBuilder to IDetailLayoutBuilder. If you want to give it another go, I suggest watching this excellent stream about extending the editor for more info.

Thanks, I’ll look into it later :slight_smile:

One exception worth noting is that using ‘!’ also works with an EditCondition, as long as you keep quotes around the condition:

 UPROPERTY(EditAnywhere, Category = Game, meta = (EditCondition = "!bCanIUse"))
1 Like

Maybe it didn’t work back when this was posted, but the following seems fine for me:

UPROPERTY(EditAnywhere, Category = Game, meta = (EditCondition = "bCanIUseA || bCanIUseB"))

Can you somehow make it appear inside the Property widget like MassInKg from the Details Editor / Physics of any object ?

250576-forumquestion.png

hmm…I just tried this and it didn’t seem to work. i’m in 4.18. i wonder if it’s in a newer build.

To make it inline, you put meta=(InlineEditConditionToggle) on the bool, along with the normal meta=(EditCondition="<nameofboolhere>")

This answer is no longer correct.

You can have multiple bools as the Original Poster asked. The bit that is slightly unexpected is the bools and the operator need to be in quotes like follows:

UPROPERTY(EditAnywhere, Meta = (EditCondition = "ConsumeOnTriggerActivator && DoesActivatorResetAfterConsume"))
float ConsumeResetDelay;

This is true on version 4.26

1 Like