EditorWindow : ScriptableObject modifications not updated/applied
Hello,
I'm working a a custom EditorWindow which goals is to populate datas in a ScriptableObject.
public class GameDBEditorWindow : EditorWindow{
public GameDB gameDB;
...
...
}
public class public GameDB : ScriptableObject{
public string[] toolbarStrings = new string[] {"one","two","three"};
...
...
}
I do not write the code that create the ScriptableObject instance neither the code that save it when it's modified - but those functions exist and work as expected.
If I do the following actions :
Load the WindowEditor
Save the assets using EditorUtility.SetDirty(this) and AssetDatabase.SaveAssets();
The gameDB is correctly saved in the disk
Add an entry in the toolbarString, let's say "four"
Save again
The toolbar displays in the editor is not updated
Closing the editor and re-open change nothing
Any idea why ? Thanks
Answer by dan-kostin · Feb 01, 2020 at 08:25 PM
You need to have assset created from ScriptableObject to store it's params.
[UnityEngine.CreateAssetMenu(fileName = "TestSO", menuName = "Test SO", order = 0)]
public class TestSO : UnityEngine.ScriptableObject
Open create menu and create Test SO asset. Then load/attach it and use it as TestSO instance.
Your answer