Unknown Identifier: 'AssetDatabase'. on build

I get this error when trying to build my game, but not when trying to run my game in unity:

Unknown Identifier: ‘AssetDatabase’.

Heres my code, why is this happening?

var loadedMaterial : Object;

function OnMouseOver () {
	var thePath = "Assets/Project/Materials/Button.mat";
	loadedMaterial = AssetDatabase.LoadAssetAtPath(thePath, Material);
	gameObject.renderer.material = loadedMaterial;

AssetDataBase is only available in the editor:

Note: This is an editor class. […]