- Home /
Assign min / max values to range in inspector.
Hello!
I need to assign min / max values to a range in the inspector trough script:
[Range(min, max)]
I get the error:
An object reference is required to access non-static member `IntInterval.min'
How do you assign values to range in inspector trough script?
maybe a silly question, but are you literally putting [Range($$anonymous$$, max)] here? because you're going to want to put your actual $$anonymous$$ and max values in there. something like [Range(0,100)]
Answer by SrBilyon · Jun 07, 2017 at 06:45 AM
I'm not sure if there's a way to do it using the [Range(min,max)] tag, but one possibility if you intend on modifying values through the inspector is the use Mathf.Clamp, creating a min and max variable, and then use those variables for the min and max in the Mathf.Clamp function.
This will allow for clamping the top and bottom value of the variable you were going to use Range against originally.
Answer by luisquid · Jun 09, 2017 at 08:59 PM
I don't think you are allowed to see static variables in the inspector.
Answer by blessthefall9 · Jun 10, 2017 at 07:36 AM
You need to make it static. Static variables can be used by all the objects of that class, but exist only once. It would be helpful to see your code.