I’m trying to load a Material from my Assets folder. I have this code to do it:
Material myMat = Resources.Load("redmat", typeof(Material)) as Material;
And the file is placed in the Assets folder (“Assets/redmat.mat”). I’ve checked “Assets/Materials/redmat.mat” too.
I’m new to Unity, so I apologize for such an easy question.
Resources.Load()
only looks in the Assets/Resources folder. The docs:
is pretty clear on this.
You have to create a “Resources” folder after assets folder. Then you have to place your materials there with or with out “Material” folder and change your code as follows.
//FILE LOCATION ASSETS/RESOURCES/MATERIALS
Material myMat = Resources.Load("Material/redmat", typeof(Material)) as Material;
//FILE LOCATION ASSETS/RESOURCES/
Material myMat = Resources.Load("Material/redmat", typeof(Material)) as Material;
,you have to create a folder called “Resources” then place materials inside it with or without material folder then change you code :
Material myMat = Resources.Load(“Material/redmat”, typeof(Material)) as Material;
Resources folder is implicit on the load function and its not created in a new project by default.