Editor Script: Load and Save Asset

I got this piece of code in an Editor script:

It’s supposed to create and modify and asset of Type LootTable.

It runs with no errors, it creates the asset with the desired name in the desired place, but all attributes in the asset are those of the defaultLootTable.

I assume that something goes wrong with saving. I suppose my saving command is wrong. How do I fix it?

Thanks!

Here’s my go-to example of creating (or modifying) a ScriptableObject and telling Unity to save it:

Look around line 266 onwards, the block of code that writes the DatasackCollection type to a disk asset.