- Home /
Question by
VSZM · Dec 03, 2014 at 09:12 PM ·
inspectorrangeconstraint
Field constraints
Is there a way unity to keep a field's value within a certain range so that it is not even possible to assign a value to it through the inspector that is outside of the range?
For example I have an int that is used for a division and I don't want myself or my fellow programmers to be able to assign a 0 value.
I know I could handle this in code, I am asking if there is a clean way of doing this with the help of the Editor.
Comment
Best Answer
Answer by theLucre · Dec 03, 2014 at 09:18 PM
Try
[Range(0,100)]
public int Health;
From http://unity3d.com/learn/tutorials/modules/intermediate/scripting/attributes
Your answer