A weird material order..

Here is my situation in my scene:
I have 3 materials…
Material A should always stay behind material B…
Material B should always stay behind material C… and
Material C should always stay behind material A.

All of these three matrials are transparent…

got some tips related to render queues on the unity channel, but… still can’t figure out the exact solution in my case.

Needing some hand…

You need to manually set the render queue for each material. Unfortunately, in your description you’re asking for something hard to do as you want Material C to be in two different rendering queues at once. If I were you I’d make a Material D :wink:

Anyway, this JS script should get you going in the right direction.

#pragma strict

public var MaterialA : Material;
public var MaterialB : Material;
public var MaterialC : Material;

function Start () 
{
	MaterialA.renderQueue = 3100;
	MaterialB.renderQueue = 3200;
	MaterialC.renderQueue = 3300;
}

3000 is the default render queue for transparent objects and each higher number will be rendered after (in front of) the lower number. Stay between 3000-4000 as 4000 goes into the overlay queue which is reserved for GUI etc.

Add this script to an empty game object and drag the corresponding materials into the A, B, and C slots in the Inspector.

Let me know if this makes sense or if I screwed anything up as I just jotted down this code :wink:

thank you for the reply…
For some reason, I could not make the script abowe work… Nothing gets effected by changing the queue…

Also, asigning a 4th material (Material D) would not work, since everything should be displayed in the order I mentioned…

Weird situation,
Any other ideas ?!

Thank you

/me bumps the topic !
There should be some way !

What are you trying to achieve and what are you doing to achieve it? Maybe we can offer another solution that doesn’t require ordering the materials.

I have a curtain (semi-transparent - black)
My characters, and their eyes.

I need the curtains to hide the characters, but not the eyes. I also need the eyes to be hid behind characters when one character is in front of the other…

In other words, one character’s eyes should always be “unlit” (or in front ?) but still be able to stay behind other characters’ bodies…