I am trying to use Scriptable objects as a datatable of all of my skills as estated in this video
Overthrowing the MonoBehaviour Tyranny in a Glorious Scriptable Object Revolution
I have a Scriptable Object that contains an array of skills
[System.Serializable]
public class Skill
{
public int idSkill;
public string title;
public Sprite imagen;
public string descripcion;
public bool desbloqueado;
public int precio;
public GameObject skillScript;
}
public class SkillData : ScriptableObject
{
public Skill[] skills;
public void OnEnable()
{
if ( skills== null) skills = Resources.Load< SkillData>("Data/ SkillData"). skills;
}
}
I have created an object of type SkillData and filled it manually with the data of the skills ( Title,descripcion,image…etc) and It works, however If ‘accidentaly’ set the element array size of the object ‘SkillData’ to 0 or use this statament
public class SkillData : ScriptableObject
{
public Skill[] skills;
public void OnEnable()
{
// Since my SkillData already created object is a SkillData type, when unity enable it call this fuction and erase my data
skills = new Skill[1];
}
}
All of my work will be deleted like if a do DROP Database ( on a real database),
It is very easy to erase all of the data by accident , so the question is
I am missing something? It is any way to ensure that the data will persist even if I erase all of the data?
Is there any way to ‘force’ unity ask you if you are sure to delete data or something similar? Is there a better way to store data in order to evade the erase of it?
Thanks in advance