Ressources.Load() return null

I have my class Save which contains some variables. I want to save it like an asset to be able to load it later. The save is good (I check the content in mode force text), but when I try to load my Asset with Ressources.Load(), this function return null.

Here is my code :

public void LoadAsset()
{
	UnityEngine.Object data;

	data = Resources.Load(assetPathAndName);
    //assetPathandName = "Assets/New Save 33.asset"
	Save tmp = (Save)data;
	
	if (data == null)
		Debug.Log("Data is null, LoadAsset has failed");
	bool loaded = (data != null);

 	if(!loaded)
	{
		data = ScriptableObject.CreateInstance<Save>();
		AssetDatabase.CreateAsset(data, assetPathAndName);	
	}
	else
		return;
	
  	AssetDatabase.SaveAssets();
}

I don’t understand why my data is null.

The problem most likely is that you do not save your asset in the Resources-folder. Resources.Load only looks in the Resources folders and their subfolders.

Unity understands your assetPathandName as “< UnityProjectfolder >/Assets/Resources/Assets/New Save 33.asset”

A word of warning: Resources.Load will most likely not work for saving and loading user-made content (incl. save games) after the game is built, as the existing Resources-folders will have been packed, thus being unmodifiable. Custom serializers can be found on the assets store to address this issue.