In this question, I wondered how to force a particular TSubclassOf<>
UPROPERTY to be non-None. It turned out there was a particular keyword which specifically selected that behavior, so hooray for that.
But more in general, I’m often running into situations where setting a particular UObject
property in the editor should be validated/handled in some way. Certain validation behaviors have associated metadata types (think ClampMin/Max
, NoElementDuplicate
, etc., but there isn’t always one which fits.
What I’d like, basically, is some way of custom-validating property changes which happen in the editor. UObject::PostEditChangeProperty
is tantalizingly close to fitting the bill, except that when it fires, the change has already been made, and there’s no way to find out what the old value was, so it can’t be reverted. (Similarly, PreEditChange
happens too soon; there’s no way to know what the new value will be).
One option might be to instantly undo the change from PostEditChangeProperty
… but initiating an undo from within a notification callback sounds dangerous, and I’m not actually sure how to go about it.