_Edit: So I have found out that EditorUtility.SetDirty() is obsolete. How do I save it then? _
I am making a Item database, inspired by BurgZerg, and for some reason, my list in the Database doesn’t save after unity reload or it erases all data after I save a the ItemDatabase.cs even tho I have EditorUtility.SetDirty() after every change.
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEditor;
public class ItemDatabase : ScriptableObject {
[SerializeField]
List<Item> items = new List<Item> ();
public void Remove(Item item) {
items.Remove (item);
EditorUtility.SetDirty(this);
}
public void RemoveAt(int index) {
items.RemoveAt (index);
EditorUtility.SetDirty(this);
}
public void Add(Item item) {
items.Add (item);
EditorUtility.SetDirty(this);
}
public int CountItems() {
return (int)items.Count;
}
public Item Item(int index) {
return items.ElementAt (index);
}
}
Take a look here:
Take a look at all the answers there, maybe one will give you a clue.