Can't load Asset with Resources.Load as Transform, but can load as GameObject

I have this:

	public void GenerateBlocks()
	{
		Block cube = new Block();
		cube.prefab = Resources.Load("Blocks/Cube") as Transform; //Returns null
		Debug.Log((Resources.Load("Blocks/Cube") as GameObject).transform); //Returns the Transform
		cube.name = "Cube";
		blocks.Add(cube);
	}
}

public class Block {
	public Transform prefab;
	public string name;
}

Loading the cube as Transform returns null, loading the cube as GameObject returns the asset. Loading it as a GameObject and getting the Transform of it returns the Transform. Is this a bug or am I missing something?

I’m on version 5.3.4f1 Personal.

When you call Resources.Load to load a prefab without providing a type it will return the GameObject of that prefab. You have to use

cube.prefab = Resources.Load<Transform>("Blocks/Cube");

or

cube.prefab = (Transform)Resources.Load("Blocks/Cube", typeof(Transform));

Usually an asset has only one type, however prefabs can contain many different types so you have to specify which one you want. So when loading Textures, AudioClips, Materials, … you wouldn’t need that. Though always using the generic version is usually easier (since you don’t need an explicit cast) and simply cleaner.