- Home /
Trying to change texture in Runtime but it goes pink?
I have been trying to change the texture at runtime but whenever i attempt it the quad just goes pink:
After looking this up for a bit it seems that this happens because the material is missing but..
// Void Start()
Left =Resources.Load("Materials/Left",typeof(Material)) as Material;
//void Update()
if (velocity.x < 0){
GetComponent<Renderer>().material = Left;
}
I have also tried this:
//void Start()
Right =Resources.Load("Left", typeof(Material)) as Material;
To clarify, i have been using quads and all these materials have the "Sprites/diffuse" Shader.
What am i doing wrong, is it the code or something else? Hopefully i got my problem across.
Thanks
Answer by tanoshimi · Apr 06, 2017 at 10:01 PM
Resources.Load is for loading assets placed in the /resources folder. Your screenshot clearly shows that the material is in the /materials folder.
https://docs.unity3d.com/Manual/LoadingResourcesatRuntime.html
Your answer
Follow this Question
Related Questions
Unity faces order bug when rendering with recorder 0 Answers
Tiling texture moving issue 0 Answers
Custom Shader with Canvas Renderer limit draw calls. 0 Answers
Use different material based on target platform 1 Answer
Batching draw calls? 2 Answers