- Home /
Why do my GameObjects have a flickering line above them?
I'm making a 2d platformer in Unity and my ground objects have a SpriteRenderer component that renders an image of some grass. However the actual grass is at the bottom of the .png which it is part of so more than half of the GameObject is clear. However, at the top of the GameObject there is a flickering green line. Does anyone know what this is and/or how to stop it?
Any chance there is a thin line of pixels in your sprite texture that don't have 0.0 for the Color.a? You should be able to enlarge and sample the pixels in Photoshop to test.
Answer by CanisLupus · Jun 25, 2014 at 07:20 PM
Assuming you don't want the grass texture to repeat inside the object, try changing the wrap mode of your texture from "Repeat" to "Clamp" in its import settings. This problem has happened to me way too many times in Unity and this is generally the solution. The bottom line of pixels sometimes "bleeds" to the top when in repeating mode.
I had the picture's import type set to sprite and now that I changed it to texture to change the wrap mode, I can't render them with a spriterenderer. How do I render textures?
You should be able to keep using your picture in sprite mode if you select the Texture Type as "Advanced" ins$$anonymous$$d of "Texture". In Advanced, you can choose sprite mode AND wrap mode.
If you want to use the picture as a texture, you must add it to a material and render it with a $$anonymous$$esh Renderer. For an example: in the menu select GameObject -> Create Other -> Quad. The Quad comes with a $$anonymous$$esh Renderer. If you drag a texture over the Quad object, Unity will apply that texture to the object. Now change the Quad's material (actually, its shader) to Unlit/Transparent. The "Diffuse" material used by default in Quads is only adequate when you have lights in the scene, and I suppose you want a clear 2D look similar to what Sprite Renderer provides by default ("Sprites-Default").
Answer by Detinator10 · Jun 25, 2014 at 05:56 PM
I didn't figure out what the line was about. But, to fix it I made the images really tall so the top(including the clear space) was off the screen. Now you can't see the green lines because they're off screen.
Your answer
Follow this Question
Related Questions
Show gameobject as part of UI 1 Answer
Unity streching sprite gameobject to fit two positions. 1 Answer
SpriteRenderer draw only part of the sprite? 1 Answer
UI Button Sizing unit 0 Answers