- Home /
Question by
ManaAura · Jul 21, 2017 at 08:11 PM ·
listserializationdatabasescriptableobjectdata storage
Scriptable Object's Data Gets Lost After Re-opening Unity!!!
Hello,
I have a trouble with scriptable object's missing data after I reopen unity... So, I have a scriptable object class that has a test list, and a function that adds strings to that list. Then I have a monobehaviour class where I call that "Add" function. Everything works perfectly, during playmode, and editor mode -The list will get populated properly. HOWEVER, when I close unity, and open it again... the list in that scriptable object becomes EMPTY .........
public class ScriptableFile : ScriptableObject
{
public List<string> test;
public void Add(string s)
{
test.Add(s);
}
}
/////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
public class TEMPTEST : MonoBehaviour {
public ScriptableFile file;
void Update () {
if (Input.GetKeyDown(KeyCode.G))
{
string s = "a string var";
file.Add(s);
file.Add("literal string value");
}
}
}
Comment
Best Answer
Answer by ManaAura · Jul 21, 2017 at 09:01 PM
Solution Found:
Create a custom editor and set it to dirty....
Tried Unity SetDirty in google? --> EditorUtility.SetDirty