Member-only story
Unity and “The associated script cannot be loaded” error
Sometimes, working with Unity can be a bit trying 😀
I was doing a fair amount of house-cleaning on a project where I was moving scripts around, changing file names etc. At some point, I apparently touched a file which was associated with game data.
Just to set the background, you can have objects in Unity which are sub-classes of ScriptableObject. These objects can be used as data containers which store data in your game — for instance, information about each level in your game — and can be loaded at runtime to change/configure aspects of your game.
This particular project had hundreds of these level data objects and I apparently moved the associated script file (the one which derived from ScriptableObject and indicated the values stored in the data file) in a way which made Unity disassociate the script file from the data files.
Hence the error.
I had not hit this particular error before, and on doing a bit of Googling, the only results I came up with for this particular error adviced either removing all your script files from your project and re-adding them, or removing all the .meta files from your project (or the scripts folder and sub-folders) and letting Unity re-create the .meta files.