Open MergandevinasanderExTenebris opened 8 years ago
I'll take a look at this over the next few days.
@jacobdufault You're calculating the number of steps from 0 to value but you should calculate the number of relative steps from attributes.Min to value instead. This way integer steps won't be off. Try something like :
float value = EditorGUI.Slider(region, label, Convert.ToSingle(element), attribute.Min, attribute.Max;
float result = Mathf.RoundToInt((value - attribute.Min) / attribute.Step) * attribute.Step + attribute.Min;
INTRO
Hello, Dear Developer! First of all let me thank you for your really GREAT product! It's extremely useful! Now I'll do my best to describe the problem. (Sorry for my possible bad English. It's not my native).
FIRST PROBLEM (there is no a constructor)
The default behavior (without Step) is OK. Everything works fine. But if we want to add some "step behavior" to our variable, for example:
we will get an error: "error CS1729: The type 'FullInspector.InspectorRangeAttribute' does not contain a constructor that takes '3' arguments". If we look at the implementation (file 'FullInspector2\Modules\InspectorRange\InspectorRangeAttribute.cs') we will see that there is the only one constructor wIth two default parameters min and max, but there is no an implementation with third Step parameter.
SECOND PROBLEM (wrong calculations with the step)
Let's add the constructor with third step parameter, it's pretty simple, because we already have the calculation logic in Editor/InspectorRangeAttributeEditor.cs file:
It seems everything is beautiful now but it is not true. Lets create some int variable with range (1, 11) and step = 2:
We should get the values: 1, 3, 5, 7, 9, 11, don't we? BUT it gives us the wrong values: 0, 2, 4, 6, 8, 10.