UE4编辑器属性的显示与隐藏

Intro #

UPROPERTIES in Unreal Engine have a bunch of useful Meta-data Specifiers which can be applied to add additional validation and functionality. This blog post explains how to use the EditCondition (and EditConditionHides) specifiers to selectively show, disable or hide properties in the editor, based upon the value of another UPROPERTY. Shout-out to Jack Magnay for the "Advanced Usage" snippet.
 
GitHub Gist: https://git.io/JJ3QC
 

Basic Usage #

This example below disables the MyNumber property when MyFlag is false.

UPROPERTY(EditAnywhere, Category="Demo")bool   MyFlag = true;UPROPERTY(EditAnywhere, Category="Demo", meta=(EditCondition="MyFlag"))int    MyNumber = 0;

editcondition
 

Basic Usage (Inverted) #

This example below is similar to the first, but disables the MyNumber property when MyFlag is true.

UPROPERTY(EditAnywhere, Category="Demo")bool   MyFlag = true;UPROPERTY(EditAnywhere, Category="Demo", meta=(EditCondition="!MyFlag"))int    MyNumber = 0;

editcondition
 

Basic Usage (Hiding) #

This example below is similar to the first, but fully hides the MyNumber property when MyFlag is true by adding the EditConditionHides specifier.

UPROPERTY(EditAnywhere, Category="Demo")bool    MyFlag = true;UPROPERTY(EditAnywhere, Category="Demo", meta=(EditCondition="MyFlag", EditConditionHides))int     MyNumber = 0;

editcondition
 

Advanced Usage (Enum) #

As of UE4 4.23 (see release notes"The EditCondition meta tag is no longer limited to a single boolean property. It is now evaluated using a full-fledged expression parser, meaning you can include a full C++ expression." - This means we can do things like disabling a properties based on the value of an enum UPROPERTY, as shown below.

//------------------------------------------------------------------------------------------------------------------------------UENUM(BlueprintType)enum class EMovementConfig : uint8{	ConstantSpeed,	Increment};//------------------------------------------------------------------------------------------------------------------------------UPROPERTY(EditAnywhere, Category="Demo")EMovementConfig  MovementConfig = EMovementConfig::ConstantSpeed;UPROPERTY(EditAnywhere, Category="Demo", meta=(EditCondition="MovementConfig == EMovementConfig::ConstantSpeed"))float            Speed = 10.0f;UPROPERTY(EditAnywhere, Category = "Demo", meta = (EditCondition="MovementConfig == EMovementConfig::Increment"))float            Increment = 1.0f;//------------------------------------------------------------------------------------------------------------------------------

editcondition

  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值