pink material in unity after scripted material change in c#

super beginner here, i looked through like a dozen threads & didnt really find anything as simple as the problem im having that i could get to work so i thought id post. heres the code i use

Material meat = Resources.Load (“materials/meat”, typeof(Material)) as Material;
gameObject.GetComponent().material = meat;

the material is clearly changing from the previous texture, but to a hot pink. kind of bare bones but i didnt want to dump my whole page of code. i dont get any errors in the console at any point in this process.

Does the folder path exist? (“Resources/materials”)

Is there a meat material inside of “Resources/materials”?


Should read these pages if you haven’t already:

https://docs.unity3d.com/ScriptReference/Resources.html

https://docs.unity3d.com/Manual/SpecialFolders.html


Also be sure to format pasted code with the 101010 button. As you can see, the code you pasted has been trimmed.