It works now! i used the code like this:
Make sure you begin with "Assets" in the path.
@CustomEditor (scriptname)
class NewBehaviourScript extends Editor{
function OnInspectorGUI()
{
var thePath = "Assets/ExampleMaterial.mat";
var loadedMaterial = AssetDatabase.LoadAssetAtPath(thePath, Material);
Debug.Log("Just loaded this material: " + loadedMaterial.name);
target.renderer.material = loadedMaterial;
}
}
Thanks Jahroy
↧