- Home /
I can't render a texture from the resources folder
I've been trying to load in a .png from the resources folder in to a build of my game and cannot get it to load the texture but project a white empty texture instead.
This is my code
private var texture : Texture;
function Start()
{
texture = Resources.Load("uv");
GetComponent.<Renderer>().material.mainTexture = texture;
}
If anyone knows what I am doing wrong that would be greatly appreciated I can't seem to find the solution cheers :)
$$anonymous$$ake sure your textures are in the Resource folder, and named properly. $$anonymous$$ake sure the import settings are set to Texture and not sprite. This should work for you.
var rend = GetComponent.<Renderer>();
rend.material.mainTexture = Resources.Load("uv") as Texture;
Both codes are working fine in the Editor if I have a Resources/uv.png in the Assets folder but does not read anything from the Resources folder created in the build
Do you mean you create the texture at runtime and save it in the resources folder? Or that you have a texture that works in the editor but not in the build?
Answer by JedBeryll · Jun 19, 2016 at 09:40 AM
texture = Resources.Load("uv") as Texture;
does this work?
Answer by Keehan12 · Jun 19, 2016 at 11:53 AM
no luck. I've also tried
texture = Resources.Load("uv", typeof(Texture)) as Texture;
and I update the mainTexture as well as at Start but still sets to a blank texture
edit: it works in the editor? I didn't check this :P still not working in a build and I have uv.png in the Resources folder
Your answer
Follow this Question
Related Questions
Texture : Black Border ? 0 Answers
Texture not rendered on OnePlus One 0 Answers
Assigning UV Map to model at runtime 0 Answers
2D Sprites Rendering Inconsistently Between Computers 0 Answers
Texture uv's offest in distance? 0 Answers