Can I use an If statement inside the header file?

Hello, I am trying to make my variables public so I can use them in the details panel.
I would like to create a few of them but hide them after a check.

UPROPERTY(EditAnywhere)
	bool ShowVariables;

	if (ShowVariables)
	{
		UPROPERTY(EditAnywhere)
		float speed = 90.f;
		UPROPERTY(EditAnywhere)
		float walkingSpeed = 70.f;
	}

The idea is that I click the checkbox in the Details panel and if the checkbox is clicked it then shows variables like speed, if I uncheck it, it hides them.
Is something like this possible?
I get an error saying I can not use the if because it expects a declaration of the if.

I think what you need to use is the EditCondition meta data inside of the UPROPERTY()

In your case it would be UPROPERTY(meta=(EditCondition = “ShowVariables”))

You can find more information here: Properties | Unreal Engine Documentation.

I hope this helps :slight_smile:

yes that was exactly what I was looking for thanks!