Subshader
{
Tags { “[name1]” = “[value1]” “[name2]” = “[value2]”} //subshader tags
Pass
{
Tags { “[name1]” = “[value1]” “[name2]” = “[value2]”} //pass tags
}
}
The Subshader tags affect all the Passes in the Subshader, the Pass tags affect only the pass where they are written.
“Queue” = “[queue name]”
“Queue” = “[queue name] + [offset]”
| Signature | Value | Function |
|---|---|---|
| [queue name] | Background | Specifies the Background render queue. |
| Geometry | Specifies the Geometry render queue. | |
| AlphaTest | Specifies the AlphaTest render queue. | |
| Transparent | Specifies the Transparent render queue. | |
| Overlay | Specifies the Overlay render queue. | |
| [offset] | integer | Specifies the index at which Unity renders the unnamed queue, relative to the named queue. |
| Signature | Function |
|---|---|
| “Queue” = “[queue name]” | Use the named render queue. |
| “Queue” = “[queue name] + [offset]” | Use an unnamed queue, at a given offset from the named queue.An example of when this is useful is in the case of transparent water, which you should draw after opaque objects but before transparent objects. |
| “RenderType” = “[renderType]” | Set the RenderType value for this SubShader. |
| “ForceNoShadowCasting” = “[state]” | Whether to prevent shadow casting (and sometimes receiving) for all geometry that uses this SubShader. |
| “DisableBatching” = “[state]” | Whether Unity prevents Dynamic Batching for all geometry that uses this SubShader. |
| “IgnoreProjector” = “[state]” | Whether Unity ignores Projectors when rendering this geometry. |
| “PreviewType” = “[shape]” | Which shape the Unity Editor uses to display a preview of a material that uses this SubShader. |
| “CanUseSpriteAtlas” = “[state]” | Whether the Sprites that use this SubShader are compatible with the Legacy Sprite Packer. |
Read tags with C#
using UnityEngine;
public class Example : MonoBehaviour
{
// Attach this to a gameObject that has a Renderer component
string tagName = "ExampleTagName";
void Start()
{
Renderer myRenderer = GetComponent<Renderer>();
string tagValue = myRenderer.material.GetTag(ExampleTagName, true, "Tag not found");
Debug.Log(tagValue);
}
}
OR
Shader.renderQueue;
By default, Unity renders geometry in the render queue specified in the [Queue] tag. You can override this value on a per-material basis. In the Unity Editor, you can do this in the material Inspector by setting the Render Queue property. In a C# script, you can do this by setting the value of Material.renderQueue using the Rendering.RenderQueue enum.
You can determine in which order your objects are drawn using the Queue tag. A Shader decides which render queue its objects belong to, this way any Transparent shaders make sure they are drawn after all opaque objects and so on.
There are four pre-defined render queues, but there can be more queues in between the predefined ones. The predefined queues are:
Background - this render queue is rendered before any others. You’d typically use this for things that really need to be in the background.Geometry (default) - this is used for most objects. Opaque geometry uses this queue.AlphaTest - alpha tested geometry uses this queue. It’s a separate queue from Geometry one since it’s more efficient to render alpha-tested objects after all solid ones are drawn.Transparent - this render queue is rendered after Geometry and AlphaTest, in back-to-front order. Anything alpha-blended (i.e. shaders that don’t write to depth buffer) should go here (glass, particle effects).Overlay - this render queue is meant for overlay effects. Anything rendered last should go here (e.g. lens flares).