UPROPERTY specifier FixedIncrement replacement?

Hi,

I’m looking for a way to set the increment for when dragging sliders for floats in the inspector. At the moment, the floats are displayed to something like 5 decimal places and when dragging it fires off lots and lots of PostEditChanged events. What I want to do is limit this. Ideally I’d constrain the float value to a specific number of decimal points, and set an increment for when it is dragged in the inspector so it only changes by steps of 0.1f for example.

I have found “FixedIncrement” which seems to at least set the interval, but it is marked as deprecated. Is there an alternative or replacement?

You don’t need to display the direct value from the slider.

Have the PostEditChanged events just calculate what it should be (truncuate/round to whatever decimal places you want) and store this value somewhere.
and/or have the displayed value read this stored value, or do the truncuation itself. This is basically free.

I wouldn’t worry too much about what is ‘fires off lots and lots’ in of itself, just make sure it doesn’t do anything expensive in these calls. Doing some simple math isn’t expensive, basic math is pretty much free. If you need to fire off something even mildly expensive (logging), then just have it only log when the value has changed by a certain delta.

have someDelta be your 0.1f or whatever



if ( FMath::Abs(lastSavedValue - currentValue) >= someDelta ) {
    lastSavedValue = currentValue;
    .. Perhaps do some rounding/truncuation...  
    .. e.g. lastSavedValue = Math::Round(lastSavedValue * 10) / 10;  // If range was 0-1, then it will now still be between 0 and 1 but fixed intervals of approx 0.1
    ...
    slightlyMoreExpensiveOperation()
}


And then only ever use lastSavedValue in other places (like your display)

Unfortunately the many repeated PostEventChanged calls are the problem because it triggers every single ChildActorComponent to destroy and re-create it’s Child Actors which is expensive. The truncating of the float isn’t the main problem here. There doesn’t seem to be any way to prevent the ChildActorComponents from doing this either as its the ChildActorComponents OnConstruction that does this.

I could always subclass the ChildActorComponent and override the OnConstruction but I’d prefer not to if there’s a better way.

For more info… when the ChildActorComponent is rebuilt, its created using default values so in my Actor PostEditChanged I’m re-applying the changed values to the new actor spawned by the ChildActorComponent. There are lots (both ChildActorComponents and properties that need re-applying).

I’ve looked at the documentation but can’t quite get my head around it, but is there a way to make the ChildActorComponent retain its properties between OnConstruction calls? It looks like using Templates is what I want but it seems difficult to find information about using them in this context…