Question by
emirkoskenli · Dec 26, 2018 at 09:34 PM ·
webglplayerprefs
Playerprefs stop saving after a while
Hi folks. I'm having a trouble with playerprefs on my WebGL game.It's working properly at the beginning but after few minutes, saving function is start delaying. Game normally autosave itself every 3 minutes. But if I plays the game one hour and reopen the game, my loaded data is about 10 minutes older. Also I'm seeing this warning error is flowing on my console; Warning: 8 FS.syncfs operations in flight at once, probably just doing extra work. This warning number continues as long as the game is open. Maybe somethings wrong on my code. Please have a look.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerPref : MonoBehaviour {
public Karakter karakter;
GameObject lvlup;
public Levelup levelup;
GameObject expver;
public WaveManager waveManager;
GameObject expSetup;
public Crafting crafting;
GameObject craft;
public Aspects aspect;
GameObject asp;
//public Achievements achievements;
//GameObject achie;
public SkillTree skilltree;
GameObject skills;
public Forge forge;
GameObject soulcraft;
public Torch torch;
GameObject lightIt;
public float savetimer;
void Start ()
{
lvlup = GameObject.FindGameObjectWithTag("karakter");
karakter = lvlup.GetComponent<Karakter>();
expver = GameObject.FindGameObjectWithTag("expbar");
levelup = expver.GetComponent<Levelup>();
expSetup = GameObject.FindGameObjectWithTag("gamemaster");
waveManager = expSetup.GetComponent<WaveManager>();
craft = GameObject.FindGameObjectWithTag("crafting");
crafting = craft.GetComponent<Crafting>();
asp = GameObject.FindGameObjectWithTag("aspect");
aspect = asp.GetComponent<Aspects>();
//achie = GameObject.FindGameObjectWithTag("achievement");
//achievements = achie.GetComponent<Achievements>();
skills = GameObject.FindGameObjectWithTag("skilltree");
skilltree = skills.GetComponent<SkillTree>();
soulcraft = GameObject.FindGameObjectWithTag("forge");
forge = soulcraft.GetComponent<Forge>();
lightIt = GameObject.FindGameObjectWithTag("torch");
torch = lightIt.GetComponent<Torch>();
savetimer = 0;
levelup.saveTime = true;
//PlayerPrefs.DeleteAll();
if (PlayerPrefs.GetInt("Saved") >=1)
{
//Karakter
karakter.karakterStartHp = PlayerPrefs.GetFloat("karakterStartHp");
//karakter.karakterHp = PlayerPrefs.GetFloat("karakterHp");
//karakter.karakterMaxHp = PlayerPrefs.GetFloat("karakterMaxHp");
karakter.healthMultiply = PlayerPrefs.GetFloat("healthMultiply");
karakter.damage = PlayerPrefs.GetFloat("damage");
karakter.damageMultiply = PlayerPrefs.GetFloat("damageMultiply");
karakter.EnemyAliveBonus = PlayerPrefs.GetFloat("EnemyAliveBonus");
//karakter.totalDamage = PlayerPrefs.GetFloat("totalDamage");
karakter.range = PlayerPrefs.GetFloat("range");
karakter.fireRate = PlayerPrefs.GetFloat("fireRate");
karakter.critChance = PlayerPrefs.GetFloat("critChance");
//karakter.critDamage = PlayerPrefs.GetFloat("critDamage");
karakter.critMultiply = PlayerPrefs.GetFloat("critMultiply");
karakter.lifeSteal = PlayerPrefs.GetFloat("lifeSteal");
karakter.penetration = PlayerPrefs.GetFloat("penetration");
karakter.damageReduction = PlayerPrefs.GetFloat("damageReduction");
karakter.poisonChance = PlayerPrefs.GetFloat("poisonChance");
karakter.poisonDamageMultiply = PlayerPrefs.GetFloat("poisonDamageMultiply");
karakter.lastStandDamageMultiply = PlayerPrefs.GetFloat("lastStandDamageMultiply");
}
}
void Update ()
{
PlayerPrefs.SetInt("Saved", 1);
savetimer += Time.deltaTime;
if (savetimer >= 200)
{
levelup.saveTime = true;
savetimer = 0;
}
if (levelup.saveTime == true)
{
SaveGame();
Debug.Log("Saved");
levelup.saveTime = false;
}
}
void SaveGame()
{
//Karakter
PlayerPrefs.SetFloat("karakterStartHp", karakter.karakterStartHp);
//PlayerPrefs.SetFloat("karakterHp", karakter.karakterHp);
//PlayerPrefs.SetFloat("karakterMaxHp", karakter.karakterMaxHp);
PlayerPrefs.SetFloat("healthMultiply", karakter.healthMultiply);
PlayerPrefs.SetFloat("damage", karakter.damage);
PlayerPrefs.SetFloat("damageMultiply", karakter.damageMultiply);
PlayerPrefs.SetFloat("EnemyAliveBonus", karakter.EnemyAliveBonus);
//PlayerPrefs.SetFloat("totalDamage", karakter.totalDamage);
PlayerPrefs.SetFloat("range", karakter.range);
PlayerPrefs.SetFloat("fireRate", karakter.fireRate);
PlayerPrefs.SetFloat("critChance", karakter.critChance);
//PlayerPrefs.SetFloat("critDamage", karakter.critDamage);
PlayerPrefs.SetFloat("critMultiply", karakter.critMultiply);
PlayerPrefs.SetFloat("lifeSteal", karakter.lifeSteal);
PlayerPrefs.SetFloat("penetration", karakter.penetration);
PlayerPrefs.SetFloat("damageReduction", karakter.damageReduction);
PlayerPrefs.SetFloat("poisonChance", karakter.poisonChance);
PlayerPrefs.SetFloat("poisonDamageMultiply", karakter.poisonDamageMultiply);
PlayerPrefs.SetFloat("lastStandDamageMultiply", karakter.lastStandDamageMultiply);
}
}
Comment