Is it possible to generate an error in the editor from c++?

Hi,

I would like to know if it is possible to generate an error in the editor from c++ (or any other way) when certain values are set. For example, I have a door class that has:

DoorState - Either “Opened” or “Closed”
IsLocked - either “True” or “False”

I would like to generate an error in the editor when the user selects “Opened” and “Locked” as this should not be a possible state for a door.

Thanks!

There CheckForErrors() function you can override:

And also IsDataValid:

Not sure about you enum states, but there a lot smoother solution, there property meta specifier called EditCondition where you put name of bool property in and it will disable the property if it’s false, you can also invert this condition with ! in property name. So in your case:

UPROPERTY(EditAnywhere, meta=(EditCondition="!IsLocked"))
EDoorState DoorState;

And 3rd solution… is simply ignore this state and assume it open, you can also put warning in log that this state should be impossible and state will fallback to opened for example

void ADoorBase::OnConstruction(const FTransform& Transform)
{
Super::OnConstruction(Transform);

	// Force the door closed if it is locked
	if (IsLocked)
	{
		DoorState = EDoorState::kClosed;
	}

	// Set the initial state of the door
	if (DoorState == EDoorState::kClosed)
	{
		this->OnDoorClosed(true);
	}
	else
	{
		this->OnDoorOpened(true);

	}
}

Thanks for your reply. I tried what you suggested but never got the result I wanted. I ended up doing what I posted above, where I force the DoorState to closed if it’s locked in the construction script. This causes the editor value to automatically update when locked is set to true so that there is no way it can be locked and opened.