Let's take a look at playerprefs APIs,
Let me explain,
Setint is to save a playerprefs. setint ("player score", 10 );,
Getint is used to read a playerprefs. getint ("player score") value. They are a pair and used as an integer for access.
As the name suggests, setfloat and getfloat are float-type access, and setstring and getstring are character-type access;
Haskey indicates that if this number exists, the returned value is true. Otherwise, false; playerprefs. haskey ("player score ");
Deletekey is the number of playerprefs. deletekey ("player score ");
Deleteall is to delete all the numbers, playerprefs. deleteall ();
Let's have a simple exercise,
Pref2.cs
Using unityengine; using system. collections; public class pref2: monobehaviour {// use this for initializationvoid start () {playerprefs. setint ("player score", 10); print (playerprefs. getint ("player score") + "---" + playerprefs. haskey ("player score"); playerprefs. deletekey ("player score"); print (playerprefs. getint ("player score");} // update is called once per framevoid Update (){}}