- Home /
How can "bounds" for script variables be defined for use in the Inspector?
Is there a way to enforce value boundaries for variables exposed to the Inspector?
Many of the built-in components have ranges to constrain script variables, but I've thus far been unable to find it in any of the documentation.
The main purpose of this is to be able to "scrum" the values during testing without them crossing some set boundary.
Comment
Best Answer
Answer by Jessy · Apr 29, 2012 at 07:18 AM
You have to use a custom inspector for this. Here's an example I made a while ago.
Answer by Vsenik · Sep 30, 2014 at 03:49 AM
This answer is first in google. But it's a little outdated. Now solution is simple as this:
[Range(0.0f,1.0f)]
public float MyVariable = 1.0f;