My question is, why _myInputField.text and _valueText.text get different numbers? _myInputField.text gets “999999799”,
while _valueText.text gets “999,999,800” (= 999999800).
I noticed that the slider max value appears on the “e+0” formatting. Maybe it’s got something to do with the issue, in which case, I don’t know how to solve it.
They are similar but not duplicates. On that thread, I was asking how to convert from one format to another. On this one, I’m asking about the behavior of the slider’s value and “n0” vs “F0”. I didn’t want to post this question on the previous thread and get someone tell me I’m off-topic and to post a new thread. But if I’m incorrect, then my apologies.
It’s got to be it, thanks. “F0” is getting the correct value, which is “999999799”. I have to delve into how the “n0” format works since it doesn’t work as I expected.
Sorry if the following question is off-topic (I don’t want to create duplicates), now I want to focus on the slider:
The slider max value is set to 999999799 (ended in 799). Then it translates into the “x.xxxe+xx” format, as seen in the inspector (in this case, “9.999998e+08”). if I convert this float value (9.999998e+08) to “long”, I get 999999800, probably because it doesn’t take into account small figures and goes by larger steps.
The only way that occurs to me to get the correct “long” is to convert the “slider max value” to string (string stringValue = _mySlider.value.ToString("F0")) and then get the “long” (long longValue= Convert.ToInt64(stringValue)). This way, I get the expected long (999999799).
However, this is not suitable since I cannot convert this long value into the slider value. If I wanted to subtract one from the long value (longValue--; (999999798)) and then set the slider value to the long value: _mySlider.value = (float) longValue, the value of the slider doesn’t change, it keeps being the same: 9.999998e+08. When translating the number, it yields 999999799 instead of 999999798. (Same happens if I did _mySlider.value--; directly)
I need the slider to handle large numbers too, is there a way to make the slider use a format that doesn’t use “e+”, or at least a workaround?
I thought of overriding this cs but it seems too overkill, not to mention that probably Unity won’t let me do it that easily. Tomorrow I’ll have a look at another option that I have in mind. I’ll report it if I succeed.
Rather than overwriting the original slider rename the class into a new one and make the necessary changes? I don’t see any internal stuff here so you should be good to go.