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

蓝图属性面板参数是否可编辑可以通过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;
};

实现效果:
UE4 控制蓝图属性面板参数是否可编辑_第1张图片
UE4 控制蓝图属性面板参数是否可编辑_第2张图片

你可能感兴趣的:(UE4,小知识)