Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by antx · Jan 20, 2016 at 10:52 AM · materialrenderqueue

material.renderQueue = 4000 has no effect.

I need an object to be rendered on top of all others in the scene. I read that I could do this by setting the renderQueue property of my material.

 GetComponent<Renderer>().material.renderQueue = 4001;

Has no Effect at all. Other objects are still covering my object. I set this within the Awake() function of a script attached to the object I want to be on top. Is there something else I have to do?
(and no other object have not the same material)

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
6
Best Answer

Answer by Eno-Khaon · Jan 20, 2016 at 11:07 AM

The Rendering Queue doesn't quite do what you think it does. While it does change the order in which objects are rendered, that doesn't change the process of determining whether to render them in the first place.

What you're looking for is part of shader code instead. In this case, this is a matter of changing the shader from the default of ZTest LEqual to ZTest Always. This will result in the object always rendering, no matter what's in front of or behind it, rather than only rendering if it is in front of another object.

That said, that doesn't mean that the Rendering Queue isn't a factor in this. If you have two objects, each set with ZTest Always, you can then be certain one will always render on top of the other by changing their position in the Rendering Queue.

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image antx · Jan 21, 2016 at 08:40 AM 0
Share

Lets say I want to use the Unlit/Transparent shader. How would I go about changing it (or copying it and adjust the copy)? When I select "Edit shader" from the menu in the inspector I get a button to compile and show the code, but that does not seem to be what I need.

avatar image revolute antx · Jan 21, 2016 at 08:56 AM 0
Share

You need to download Unity's internal shaders if you are going to use shaders Unity provides. For other cases, do whatever you wish to do with it, any text editor is good enough.

avatar image antx · Jan 21, 2016 at 11:30 AM 0
Share

Okay, thanks to the two of you. I got it to work just as I wanted it. Downloaded shaders, made a copy of the unlit-alpha shader, set queue tag to "overlay" and added a "ZTest Always" line.

avatar image ubu2600 · Mar 24, 2017 at 02:06 PM 0
Share

This was tremendously helpful, thank you.

avatar image ComputerCables · Oct 01, 2018 at 08:14 PM 0
Share

O$$anonymous$$G Thanks!

avatar image l0calhost · Nov 08, 2021 at 08:11 PM 0
Share

Finally! I had been struggling with a similar problem for quite some time and the ZTest value hint solved it. Thanks!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

38 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Sprite behind semi transparent mesh 0 Answers

crash when material access renderQueue property 0 Answers

How to permanently set the renderQueue variable for a material? 2 Answers

Material doesn't have a color property '_Color' 4 Answers

3d Object always behind with Render Queue doesn't work? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges