- Home /
Scriptable Object not saving changes to a list.
Hey. So im very new to using scriptable objects but am working on an item database.
I have scriptable objects for each of my items and a scriptable object for my database(this just contains a list of Items)
I have a function that i call in the editor called ValidateDataBase, which gets all the items and adds them to the list.
Here is my code:
public static void ValidateDataBase (){
ItemDataBaseManager _myDataBase = (ItemDataBaseManager)AssetDatabase.LoadAssetAtPath ("Assets/Resources/ItemDataBase/ItemDataBase.asset", typeof(ItemDataBaseManager));
if (_myDataBase != null) {
_myDataBase.ClearDataBase ();
BaseItem[] items = Resources.LoadAll<BaseItem> (@"ItemDataBase");
foreach (BaseItem item in items) {
_myDataBase.AddItemToDataBase (item);
}
Debug.Log("Validated Item DataBase.");
} else {
Debug.LogWarning("Failed Validated Item DataBase. DataBase Doesnt Exist.");
}
AssetDatabase.SaveAssets ();
AssetDatabase.Refresh();
}
So this works and it adds my items to the database list(a scriptable object) BUT after i close unity and open it again my list is empty. Its likely i just dont fully understand how saving assets work.
Any help would be great. Thanks ~Scott
Your answer
Follow this Question
Related Questions
Referencing a ScriptableObject asset programatically 0 Answers
Saving changes to the asset files for Prefab and Scriptable objects. 1 Answer
Creating new scriptable objects at runtime 1 Answer
Assets was changed message after scene Run/Stop in Editor 3.2. 0 Answers
ScriptableObject List doesn't save 1 Answer