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();
}
}