Make an 3D gameobject render on top of all other objects.

Ok I have seen this answered once or twice before but they were not well explained and I could not get them working. How do I get a 3D mesh to be rendered above all other objects, or in other words, no matter what is covering the object up, the player will always be able to see it. Even if there is a wall between the player and the object.

What I am trying to do is create a dynamic icon for my inventory system. I am attempting this by creating an instance of the 3D GameObject in question, shrinking it down, and placing it on the screen on top of the inventory slot so that the slot appears to contain the object. Now the problem is that if the player is too close to a surface, the inventory item is rendered behind that object, which is what one would normally expect but in this case I need to override that functionality.

I have already tried setting the objects material render queue as such:
renderer.material.renderQueue = 4000;
and also tried creating a custom shader that uses:
Tags { “Queue” = “Overlay” }
and neither of these methods worked on their own nor in concert. I got no compile errors but the item continues to be rendered behind other geometry.

Can anyone tell me what I am doing wrong?
Thanks in advance : )

P.S. My code if it is needed:

Inventory Code Snipt:

//Add an item to the inventory
function AddInventory(Item : Transform) : boolean
{
	//set up index
	var i : int = 0;
	//Get instance of invntory item
	var NewItem : Transform = Instantiate(Item, transform.position, transform.rotation);
	//Get script
	var Pickup : InventoryItem = NewItem.GetComponent(InventoryItem);
	
	//bind this object to the player
	NewItem.parent = transform;
	
	
	//if stackable
	if(Pickup.MaxStack != 1)
	{
		//find first open stack
		for(i = 1; i < 11;)
		{	
			if(QuickBar*.QScript != null)*
  •  	{*
    

_ Debug.Log("Slot " + i + " script name = " + QuickBar*.QScript.ItemName);_
_ if(QuickBar.QScript.ItemName == Pickup.ItemName)
{
Debug.Log(“GotMatch”);
if(QuickBar.QScript.MaxStack == 0)
{
QuickBar.Count++;
Destroy(NewItem.gameObject);
return true;
}
else if(QuickBar.Count + 1 <= QuickBar.QScript.MaxStack)
{
QuickBar.Count++;
Destroy(NewItem.gameObject);
return true;
}
}
}
i++;
}
//find first empty slot*

* for(i = 1; i < 11;)
{
if(QuickBar.QScript == null)
{
QuickBar.QItem = NewItem;
QuickBar.QScript = Pickup;
QuickBar.Count = 1;*_

_ QuickBar*.QIcon = Instantiate(Item, transform.position, transform.rotation);
QuickBar.QIcon.GetComponent(MeshRenderer).enabled = true;
QuickBar.QIcon.renderer.material.shader = Shader.Find(“Custom/GUIShader”);
QuickBar.QIcon.renderer.material.renderQueue = 4000;
QuickBar.QIcon.localScale = Vector3(0.1, 0.1, 0.1);
QuickBar.QIcon.parent = Camera.main.transform;*_

_ QuickBar*.QScript.SetOwner(this);*_

* return true;*
* }*
* i++;*
* }*

* }*
* else*
* {*
* //find first empty slot*
* for(i = 1; i < 11;)*
* {*
_ if(QuickBar*.QScript == null)
{
QuickBar.QItem = NewItem;
QuickBar.QScript = Pickup;
QuickBar.Count = 1;*_

_ QuickBar*.QIcon = Instantiate(Item, transform.position, transform.rotation);
QuickBar.QIcon.GetComponent(MeshRenderer).enabled = true;
QuickBar.QIcon.renderer.material.shader = Shader.Find(“Custom/GUIShader”);
QuickBar.QIcon.renderer.material.renderQueue = 4000;
QuickBar.QIcon.localScale = Vector3(0.1, 0.1, 0.1);
QuickBar.QIcon.parent = Camera.main.transform;*_

_ QuickBar*.QScript.SetOwner(this);*_

* return true;*
* }*
* i++;*
* }*
* }*
* Destroy(NewItem.gameObject);*
* return false;*
}
Custom Shader:
Shader “Custom/GUIShader” {
* Properties {*
* MainTex (“Base (RGB)”, 2D) = “white” {}*
* }
SubShader {
Tags { “Queue” = “Overlay” }
LOD 200*_

* CGPROGRAM*
* #pragma surface surf Lambert*

* sampler2D _MainTex;*

* struct Input {*
* float2 uv_MainTex;
_ };*_

* void surf (Input IN, inout SurfaceOutput o) {*
* half4 c = tex2D (MainTex, IN.uv_MainTex);*
* o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG*

* }
FallBack “Diffuse”
}*_

Not sure why you haven’t been successful with the render queue approach, but if you

…put it on its own layer and

…create a camera that only renders that layer and

…set that camera’s depth to be above the main camera, and

…set the camera to DepthOnly

it will definitely work.