PropertyRange attribute displays error with negative range direction when retrieved via property references

Issue #803 resolved
Julien Heimann created an issue

This is the result when setting [PropertyRange] to a negative value range (positive min → negative max) via string property reference (nameof(SomeValueProperty))
When the values are set directly as doubles this error doesn’t display.
But the range is in both cases always treated as negative → positive, ignoring the actual value directionality (positive → negative).
The directionality might be a design limitation, but the error atleast shouldn’t display when using property reference values

The odin Version in use is actually 3.0.7.0, but the dropdown in the issue editor didn’t have that value, so i selected 3.0.6.0 as the closest.

Comments (8)

  1. Tor Esa Vestergaard

    Do I understand it correctly that the issue here is that you cannot use [PropertyRange(min: 0, max: -100)] where max is lower than min?

  2. Julien Heimann reporter

    Somewhat. I can try to rephrase what i already wrote: PropertyRange can be used with direct values (0, 1) or with references to other properties or expressions (“OtherValueProperty”) (“@SomeWrapper.Value”). When used with the reference arguments and the values that are resolved from those arguments are what you wrote (positive to negative, for example (0, -100)), it prints this error, when used with direct values there’s no error. It’s somewhat usable in both cases as the slider can still be used, although the range of the slider is inverted, it’s always from -100 to 0 in this example, not from 0 to -100. This is (not ideal, but) tolerable, but the error is confusing as there’s no actual error in those properties or the values they return.

  3. Antonio Rafael Antunes Miranda

    The PropertyRange constructor without resolved strings rearranges the values if min < max or max > min which assures that -100 is always the min value in this case. The constructors with a resolved string do not do this which means that min = 0 and max = -100. This will trigger the PropertyRangeValidator that checks if

    n >= min && n <= max

    so if we test it with [PropertyRange(0, “ThisResolvesToMinus100”)] and we set the slider to -50 we get:

    -50 >= 0 && -50 <= -100 which is false

    Fix: Rearranging the values inside the validator the same way that the “non-resolved” constructor uses, before checking if they’re in range, fixes this.
    ”Fix”: Change the attribute argument order so that your negative number is the min value which has the same behaviour since the slider is always the same for both cases.

  4. Julien Heimann reporter

    Changing the attribute order is not an option as it doesn’t prevent the problem (input values are not chosen by me), so an internal fix is the best option here.

  5. Antonio Rafael Antunes Miranda

    I thought so, but I still wanted to document the possibility 🙂 that would’ve been a temporary fix anyways since it shouldn’t have to matter which comes first (same as the non-resolved way).

  6. Log in to comment