Question by
Bob-The-Zealot · Aug 31, 2015 at 12:36 PM ·
playerprefsintsimpleincrementeasy
Faster Way to Increment PlayerPrefs Int
I usually do this to increment a PlayerPrefs
int:
PlayerPrefs.SetInt ("Int", PlayerPrefs.GetInt ("Int") + 1);
I find it very slow and annoying to type.
Is there something like PlayerPrefs.GetInt ("Int") ++;
?
Sorry if this is a stupid question.
Comment
Best Answer
Answer by Dave-Carlile · Aug 31, 2015 at 12:58 PM
Why not write a helper function to do that for you?
public static class PlayerPrefsHelper
{
public static void IncInt(string key)
{
PlayerPrefs.SetInt(key, PlayerPrefs.GetInt(key) + 1);
}
}
Call it like this:
PlayerPrefsHelper.IncInt("Int");
Over time you can end up with tons of these sorts of helper functions that make life a little easier.