Object turns pink when changing material at real time:

Im using quads with “Sprite/diffuse” shading on the materials for a 2D game.

im trying to load from the materials folder using C#:

91495-path.png

	Megaderp= Resources.Load("Megaderp", typeof(Material)) as Material;
		Left =Resources.Load("Player",typeof(Material)) as Material;
		Right =Resources.Load("Left", typeof(Material)) as Material;

in a different attempt, I tried this to specify where the folder the materials are located:

    	Megaderp= Resources.Load("Materials/Megaderp", typeof(Material)) as Material;
    		Left =Resources.Load("Materials/Player",typeof(Material)) as Material;
    		Right =Resources.Load("Materials/Right", typeof(Material)) as Material;

when trying to render the new material im doing:

if (velocity.x < 0) {
			GetComponent<Renderer>().materials[0] = Left;

		}

I have also tried different methods of rendering it but the result is usually the same with each attempt, apperantly pink usually means that a file is missing, so my best guess is that im either loading the Resources wrong or im just rendering it incorrectly. (or both!)

Thanks!

Good news, should be a simple fix!

The path you are loading from has to either be a folder named ‘Resources’, or underneath a folder named ‘Resources’.