Playerprefs doesn't save anything.

I’m trying to make a 30x30 block area in which every block has a script that saves it’s values according to the position to the block. But for some reason the playerprefs doesn’t save the values. Here’s the script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class scri : MonoBehaviour {

    public Mesh[] meshes;

    public MeshFilter meshf;

    public int loaded;

    public int meshNumber;

    public string position;

    public string hasLoadedposition;

    void Start () {

        position = transform.position.x + ":" + transform.position.y;
        hasLoadedposition = position + "hasLoaded";


        PlayerPrefs.GetInt(hasLoadedposition, loaded);

        if(loaded == 1)
        {
            Debug.Log("saved and loaded correctly");
        } else
        {
            Debug.Log("loading for first time or error");
            PlayerPrefs.SetInt(hasLoadedposition, 1);
        }

        meshf = GetComponent<MeshFilter>();

        meshNumber = Random.Range(0, meshes.Length);


        meshf.mesh = meshes[meshNumber];

    }

    public void DeleteAll()
    {
        PlayerPrefs.DeleteAll();
    }

}

You have to call PlayerPrefs.Save() to actually save them to disk. Otherwise you’re just changing the runtime copy.

This means that you can choose when to save things. It’s handy if, for example, you only want a player’s progress to be saved on completion of a level.

At first glance it looks like you are setting the int asLoadedaposition string different depending on where the object is. So your calling a player pref that doesn’t exist.