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.
Answer by Jessespike · Jul 06, 2016 at 08:25 PM
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.
right, no resources folder. i figured i only needed to do that if i didnt want to specifically load the materials before assigning them. works perfectly now thanks!