Quantcast
Channel: Questions in topic: "playerprefs"
Viewing all articles
Browse latest Browse all 1333

Playerprefs doesn't save anything.

$
0
0
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(); meshNumber = Random.Range(0, meshes.Length); meshf.mesh = meshes[meshNumber]; } public void DeleteAll() { PlayerPrefs.DeleteAll(); } }

Viewing all articles
Browse latest Browse all 1333

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>