- Home /
Scriptable objects become volatile on android
Hi there, I wanted to use a class to hold some player properties like current level,name etc.So i made a class which extends scriptableObject .The data stays fine in editor but when i test it on an android device(close the game and reopen it) it resets to default values. The code is as follows
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
[CreateAssetMenu()]
[Serializable]
public class PlayerData : ScriptableObject {
[SerializeField]
public string playerName = "Player";
[SerializeField]
public int currentLevel;
[SerializeField]
public int hints=0;
}
Answer by nbaris · Jul 06, 2017 at 12:36 PM
The fact that the class is 'Serializable' means literally that - it can be serialized into some simple binary representation. That doesn't say anything about what you do with that serialization.
The Unity editor does the work of utilising serialization to persist the serializable object. The built product on Android doesn't - you have to actually go ahead and save/load your serialization to/from a file.
Thank you nbaris. I have used xml serialization.
Your answer
![](https://koobas.hobune.stream/wayback/20220612084539im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Get Reliable Instance ID 0 Answers
Saving players progress in ScriptableObject asset 1 Answer
Some data of scriptable object resets when Unity Editor restarts 0 Answers
How to store int[][] as persistent data? 2 Answers
How to save custom data types 1 Answer