How do I save; then load an array of Lists or a List of arrays (of ints)?

I have one of each, both large, and populated with values calculated in Awake() at great CPU expense.
So I want to calculate them once, then look for and load them every time after that.

I can’t find a clear or satisfactory answer either here or in the docs. I just know that they have to be serialized and while that seems like something I should be able to achieve in three lines of code or less, every time I try to read up on how to serialize things I find myself wanting to bang my head on the keyboard.

I suggest you to use ArrayPrefs, which is developed by the Volunteer Moderator Eric5h5.

The first version of this has the minimum requirements for saving and loading array, but the second version is perfectly developed for any types of array, and this two versions are also available in CSharp and UnityScript.

This is the link to ArrayPrefs version 1, and this is the link to ArrayPrefs version 2. Enjoy!

I’m using a ScriptableObject to save my Lists.

First, you need a class, which holds your List<> and will be saved as an .asset file:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

[System.Serializable]
public class AssetFile : ScriptableObject
{
	public List<int> mySavedList = new List<int>();
}

Then, in your working code, you need to load your .asset. If it doesn’t exist, you need to create a new one:

using UnityEngine;
using UnityEditor;
using System.Collections;

public class MyClass : EditorWindow
{
    public AssetFile myAssetFile;
    ...

    void OnEnable()
    {
        myAssetFile = (AssetFile)AssetDatabase.LoadAssetAtPath("MyLists.asset", typeof(AssetFile));
    
        if (!myAssetFile)
        {
            myAssetFile = ScriptableObject.CreateInstance<AssetFile>();
            AssetDatabase.CreateAsset(myAssetFile, "MyLists.asset");
        }

        myAssetFile.hideFlags = HideFlags.NotEditable;

Then you can create your Lists, ‘link’ them with your .asset file, change them etc… Important: After you made any change in you List, make sure you saved them in your file. For this just call EditorUtility.SetDirty(…):
`

        // Create a List<>
        List<int> workingList = new List<int>();

        // Do something with the List and put it into your file...
        myAssetFile.mySavedList = workingList;

        // Now your workingList is referenced in your file
        // And you can see your data in the Inspector if you select your asset file
        // Now that you made changes to your List, save them! Or they are lost when you close Unity
        EditorUtility.SetDirty(myAssetFile);

        // You can load your saved List as well
        workingList = myAssetFile.mySavedList;
    }
}

This method works very well in my custom EditorWindow, don’t know if it works in any other situation.
`