How to add the values of all playerpref ints with

How do I add the values of integers in playerprefs that have “score” in their names?

Sadly that i know of, there is no way to add,subtract, or do any mathematical calculations with the playerprefs. However you can get the playerprefs values, set them equal to variables in a script, add those variables together and set the end variable to the “score” in the playerprefs.

Alright so lets say you have two integers that you stored in the playerprefs, the first integer is called num1 and the second is called num2. If you wanted to get those numbers out of the playerprefs and add them together to store a new integer called score you would use:

 int newNum1 = PlayerPrefs.GetInt ( "num1" ); // Get "num1" assign it to newNum1
 int newNum2 = PlayerPrefs.GetInt ( "num2" ); // Get "num2" assign it to newNum2

 int newScore = newNum1 + newNum2; // Add newNum1 and newNum2

 newScore = PlayerPrefs.SetInt ( "score",newScore ); // Use .SetInt to set newScore

I hope this helps, if you have any questions please ask :slight_smile: