- Home /
Playerpref.SetInt enterd with a float.
So I want to save a float, or either a int with the following info:"1.2". Is there any way to do this? Because when you force it to be an int it rounds down to 1.
You probably don't need the code, but here you go ;p.
PlayerPrefs.SetInt(((AttrName)i).ToString() + " - Level Modifier", (int)PlayerController.GetAttr(i).LevelMod);
And yes I have googled.
Seems like it would be a lot easier to just keep track of two ints...
Answer by njpatter · May 16, 2014 at 02:57 PM
Is there a reason you can't use SetFloat/GetFloat ? https://docs.unity3d.com/Documentation/ScriptReference/PlayerPrefs.SetFloat.html
Answer by Graham-Dunnett · May 16, 2014 at 09:32 PM
Convert the float into an int. This gives you the 1. Save that as an int. Then subtract 1 from your float, then multiply by 10. Then convert that into an int. This gives you the 2. Save that as an int.
Your answer
![](https://koobas.hobune.stream/wayback/20220613145201im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Can I create a list with an int/float and a string? C# 2 Answers
I dont want Decimals :P 1 Answer
How do I sort floats by highest to lowest value? 1 Answer
What is the max float? -1 Answers
what the hell is a int? (or a float, or boolean, or string!) 3 Answers