UE4 控制蓝图属性面板参数是否可编辑

本文介绍如何使用UPROPERTY宏中的meta=(EditCondition=“变量名”)来控制蓝图属性面板参数的可编辑性,并通过示例代码展示了不同条件下的属性编辑状态。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

蓝图属性面板参数是否可编辑可以通过UPROPERTY宏中的meta = (EditCondition = “变量名”)控制

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"

UENUM()
enum class ETest : uint8
{
	Default = 0 UMETA(DisplayName = "Default"),
	one = 1,
	two = 2,
	three = 3,
	four = 4
};

UCLASS()
class YJ_API AMyActor : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	AMyActor();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

public:
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Test)
		bool CanEdit;
	//AdvancedDisplay:属性被显示在细节面板的高级下拉框中。
	//EditCondition:通过一个成员控制其他成员的可编辑属性。
	UPROPERTY(EditAnywhere, AdvancedDisplay, BlueprintReadOnly, Category = Test, meta = (EditCondition = "CanEdit"))
		ETest TestEnum;
	UPROPERTY(EditAnywhere, AdvancedDisplay, BlueprintReadOnly, Category = Test, meta = (UIMin = "0", UIMax = "255", EditCondition = "CanEdit"))
		int32 TestNum;
};

实现效果:
在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值