Is it possible to re-parent a blueprint when a certain option in the blueprints tab is clicked?
e.g. I got an enum. Is it possible to change the blueprint’s base class when a certain enum type is choosen? The base classes are in c++.
Another related question. Suppose I chose a certain Enum in the blueprints tab, how to make certain options in the details panel visible and hide other options. I had seen a few post regarding it.
First thing is not possible. Second option can be possible but you cannot hide/unhide it but instead you can enable/disable them using ***PostEditChangeProperty. ***Here is an example:
TestActor.h
#pragma once
#include "GameFramework/Actor.h"
#include "TestActor.generated.h"
UENUM(BlueprintType)
enum class ETestEnum : uint8
{
MyOption1,
MyOption2
};
UCLASS()
class PROPERTYTEST_API ATestActor : public AActor
{
GENERATED_BODY()
public:
ATestActor();
// Boolean property that decides if the float variables should be editable
UPROPERTY()
bool bEnableProperty;
UPROPERTY( EditAnywhere, Category = "Test Actor" )
ETestEnum MyTestEnum;
UPROPERTY( EditAnywhere, Category = "Test Actor", meta = (EditCondition = "bEnableProperty") )
float MyFloat1;
UPROPERTY( EditAnywhere, Category = "Test Actor", meta = (EditCondition = "bEnableProperty") )
float MyFloat2;
UPROPERTY( EditAnywhere, Category = "Test Actor", meta = (EditCondition = "!bEnableProperty") )
float MyFloat3;
UPROPERTY( EditAnywhere, Category = "Test Actor", meta = (EditCondition = "!bEnableProperty") )
float MyFloat4;
#if WITH_EDITOR
// Called when you change a property
virtual void PostEditChangeProperty( FPropertyChangedEvent& PropertyChangedEvent ) override;
#endif
};
TestActor.cpp
#include "PropertyTest.h"
#include "TestActor.h"
ATestActor::ATestActor()
{
}
#if WITH_EDITOR
void ATestActor::PostEditChangeProperty( FPropertyChangedEvent& PropertyChangedEvent )
{
switch (MyTestEnum)
{
case ETestEnum::MyOption1:
// Disable editing of variables MyFloat1 and MyFloat2
bEnableProperty = false;
break;
case ETestEnum::MyOption2:
// Enables editing of variables MyFloat3 and MyFloat4
bEnableProperty = true;
break;
default:
break;
}
Super::PostEditChangeProperty( PropertyChangedEvent );
}
#endif