The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?

Hi, I’ve made an app which will run through android, everthing was fine, code was working, etc until I was trying to build. It gave me the error which stands in question title above. I searched for the answer and found something (for instance: "UnityEditor" namespace not found... - Unity Answers) but nothing solved my problem.

so my question is: I just want to know whether it’s possible or not, I want to make an apk which contains a codescript that allows me to collect all materials through codebehind. As I said until I want to build everything was perfect.

and also if there is another way to do it what should I make?

here is my code

	void loadMaterials()
	{
 		string materialsPath = (Application.dataPath+"/materials");
		string[] aMaterialFiles = Directory.GetFiles(materialsPath, "*.mat", SearchOption.AllDirectories);
		materials = new Material[aMaterialFiles.Length];
		int i = 0;
		foreach(string matFile in aMaterialFiles)
		{
			string assetPath = "Assets" + matFile.Replace(Application.dataPath, "").Replace('\\', '/');
			Material sourceMat = (Material)AssetDatabase.LoadAssetAtPath(assetPath, typeof(Material));
			materials *= sourceMat;*
  •  	i++;*
    
  •  }* 
    
  • }*

The problem is that the UnityEditor library does not exist in standalone builds on any platform. In this case, AssetDatabase is part of UnityEditor, and that’s what’s causing the problem.

In general, Unity wants you to use references to assets, not explicit searching like this. The one exception is files stored in Resources folders, which you can load with the Resources class functions.