- Home /
How to Display Sprite Renderer like GUI Texture in 3D?
Hello. I created a Sprite Renderer, it has sprite sheet animation.
I would like to display it like GUI Texture in 3D, i.e.
always displayed regardless of the position of the camera
display position is given by a screen coordinate
display over all other 3D objects
I tried to assign screen position to v2f vertex(SV_POSITION) in sprite shader, but it displayed at unexpected position and disappeared when camera moved a certain distance.
(When the camera does not move, sprite does not disappear)
How can I display Sprite Renderer like GUI Texture in 3D?
Sorry my English is limited. I thank you for reading it through.
Answer by eezSZI · Jan 14, 2014 at 05:40 PM
If you want to use it like a HUD, you could create a separate orthographic camera and put the sprite in front of it. Then set that camera to be rendered last. Otherwise you could write a script to have the texture always face the camera?
I'm not exactly sure how you want the sprite to interact with the world though.
Thanks eezSZI, I created a new orthographic camera for UI, set Clear Flags Depth Only, set Depth 1($$anonymous$$ain Camera's Depth is -1).
It works fine! This is what I want exactly.
Thank you very much.
@Jotunn, I convert your "answer" into a comment. Please, don't comment in answers.
Answer by LucasReis · Jan 10, 2014 at 02:29 PM
You have to make sure the material attached to the sprite renderer is the Sprites-Default, if you do that, i'm pretty sure they will behave as you wanted
Thanks LucasReis, but still I can't reach to the result I want.
I created new Project, new scene and new sprite renderer, and make sure the material attached to the sprite renderer is the Sprites-Default.
The result I got is this.
The result I want is below. (GUI Texture)
GUI Texture is useful, but I want to use sprite sheet animation and custom shader.
Your answer
Follow this Question
Related Questions
how to use texturepacker json in unity3d 0 Answers
How to deal with an animation from sprites of different sizes? 0 Answers
OnBecameInvisible not working for Sprite 2 Answers
Updating Sprite texture leaves red outline 1 Answer
for a 2d background, sprite or a quad with shader, would be best? 0 Answers