ScriptableObject not remembering a Dictionary

I have a scriptable object that doesnt seem to “remember” things between play sessions, at least nothing more complex than an int.

public class WorldData : ScriptableObject
{
    public Dictionary<string, Region> regions;
    [SerializeField] public int worldWidth = 40;
    [SerializeField] public int worldHeight = 20;
    public GridSpot homeGrid;

    public void BuildRegions()
    {
        Debug.Log($"Regions are null: {regions == null}");
        Debug.Log($"HomeGrid is null: {homeGrid == null}");
        homeGrid = new GridSpot(worldWidth / 2, worldHeight / 2);
        regions = new Dictionary<string, Region>();
        for (int x = 0; x < worldWidth; x++)
        {
            for (int z = 0; z < worldHeight; z++)
            {
                GridSpot grid = new GridSpot(x, z);
                regions[grid.String()] = new Region(grid, regionTerrain.plains);
            }
        }
        regions[homeGrid.String()] = new Region(homeGrid, regionTerrain.home);
        Debug.Log($"Regions are null: {regions == null}");
        Debug.Log($"HomeGrid is null: {homeGrid == null}");
    }

Ive created the SO and attached it to a Monobehavior script that calls BuildRegions(); everything runs fine, but the first debug.Log returns true (regions is null) if i run it multiple times in a row. Shouldnt the first time i run BuildRegions, “fill” the regions variable and then it should persist until replaced on subsequent runs? I’m just learning SO and I can’t figure out what the problem is or what im misunderstanding.

If i change worldHeight, it remembers it between play sessions. Can SOs only remember simple class types?

Thank you. I’ve tried finding the answer to this, but can’t seem to find the right google string.

any help?

Unity can’t serialise dictionaries by default. However, a SerializedDictionary class exists in UnityEngine.Rendering if you are using URP or HDRP. You can use this class and the data will be successfully saved between sessions.

See https://docs.unity3d.com/Manual/script-Serialization.html for a overview of what Unity can and cannot serialise. In general Unity is really good at serialisation now, and most things you can serialise with no or very little setup.