- Home /
Sprites missing on build
Hey guys, this is a really really annoying thing that has been questioned before, but as far as i know, none of the questions have an answer that solves the problem. I am making an FPS, and it is almost finished. I am talking about 2 weeks of work, and i am very frustrated by this minor problem that is basically ruining my project. In my game, i always have two Canvas. The standard canvas that show some images and a timer, and what i conveniently named "Sub-Canvas" for my character, that display health and ammo. My problem is that after building the game, both canvas basically don't work. The sprites became square and purple (missing material). What am i supposed to do? I've searched a LOT and found only things like layer order and script order but this really don't work. What do i do? I can't play with those purple things on the screen, and it is very disorienting and "Unplayable".
Btw it runs fine in the editor, it only happens in the build. Dragging them into the scene as objects also work, so the problem is with the canvas!
Is it only happening when you build? or does it also happen in game display within Unity? also, how are you loading the Sprites onto the Image components? Are you dropping and dragging them through the inspector? or are you loading them another way?
(You should show us some Code)
@losingisfun Only when you build, and just dragging them. I have some scripts related to a slider and a text, but this doesn't apply at all to the images.
This may sound obvious, but are your sprites located somewhere within the Assets folder? because anything outside that folder doesn't go into the build (I don't think)
Are you using custom shaders ? Does these shaders support your build target ?
I would try to create a new project and replicate JUST the canvas that you are trying to use. Use the same scripts, and then you can try to debug it in a control
Going to try, but as i said, i don't have any script that uses the images themselves.
Yeah, but how can i know what is the problem now? $$anonymous$$ i think. Oh man this is going to take a life...
just keep trying to replicate it identically. Even folder names. You could have named one particular folder with a symbol that it doesn't like. Who knows
This doesn't help me at all, i would take AGES to discover the issue IF i discovered, and i really need to release this game as soon as possible =C
Answer by Bryangs · Jan 04, 2017 at 07:46 PM
I found an answer for it. Finally... At least i hope this answer will help someone, because i know that someone will have this problem in the future, like a lot of people did in the past.
In the end, i didn't discovered what was the cause of the bug, and as i can't configure the build i can't know why is it happening, but i tried this, and it might help you, who knows:
1- Creating and moving the images to a folder named "Resources". 2- Reimporting the Images. 3- Deleting and creating another Canvas. 4- Dragging the Images to the screen as GameObjects and making another build. 5- Trying with other images. 6- Unninstalling and Reinstalling Unity. 7- Adding ui shaders to exceptions (always load). 8- Changing script order. 9- Adding shaders to load on start.
If none of these work, and they probaly won't, this fixed my problem:
Create a material for every sprite you are having this bug, and add the image to it. Then change the material's shader to UNLIT > TRANSPARENT. Then, in your canvas, apply each material to it's image. For some reason, after building the project, these materials will not be deleted. This is a quick fix, but of course i am still having problems with texts and it's just annoying to use one material to each image, but that's the only thing that worked.
I sincerely hope this will NEVER happen to you.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Image renderer stretching sliced images 1 Answer
Blank result from build and run 3 Answers
Circular 9 slice? Draw a circle with constant thickness 1 Answer
No Windows Build Support? 1 Answer