- Home /
Multiple planes on top of each other
I'm creating AR app with Unity and Vuforia. I'm trying to create a 2D scene with multiple planes on top of each other. But the planes act very odd. How do I get them to go neatly on top of each other ja look the same both in the Unity View and the actual iPhone AR Camera view?
I had the same problem... Worked it around with dynamicly created shaders. For each plane I've created a shader that gets layer number of the plane. This is one example:
public static string Default2D (int layer)
{
return "Shader \"Custom/Default2D\" {Properties { _Color (\"$$anonymous$$ain Color\", Color) = (.5,.5,.5,1) _$$anonymous$$ainTex (\"Base (RGB) Trans (A)\", 2D) = \"white\" {}}SubShader { Tags {\"Queue\"=\"Transparent+" + ($$anonymous$$axLayers - layer).ToString () + "\" \"IgnoreProjector\"=\"True\" \"RenderType\"=\"Transparent\"} LOD 100 ZWrite Off Blend SrcAlpha One$$anonymous$$inusSrcAlpha Lighting Off Pass { SetTexture [_$$anonymous$$ainTex] { constantColor [_Color] combine texture+-constant,texture*constant } } }}";
}
Where should this bit of script go? Totally new to Unity and scripting here...
well, I assume you have created your planes in editor... if that's the case you can make something like this:
int $$anonymous$$axLayers = 1000;
int layer = 0;
Object[] objects = GameObject.FindObjectsOfType(typeof(GameObject));
foreach (GameObject go in objects) {
layer++;
$$anonymous$$aterial m = new $$anonymous$$aterial("Shader \"Custom/Default2D\" {Properties { _Color (\"$$anonymous$$ain Color\", Color) = (.5,.5,.5,1) _$$anonymous$$ainTex (\"Base (RGB) Trans (A)\", 2D) = \"white\" {}}SubShader { Tags {\"Queue\"=\"Transparent+" + ($$anonymous$$axLayers - layer).ToString () + "\" \"IgnoreProjector\"=\"True\" \"RenderType\"=\"Transparent\"} LOD 100 ZWrite Off Blend SrcAlpha One$$anonymous$$inusSrcAlpha Lighting Off Pass { SetTexture [_$$anonymous$$ainTex] { constantColor [_Color] combine texture+-constant,texture*constant } } }}");
m.mainTexture = go.renderer.material.mainTexture;
m.color = go.renderer.material.color;
go.renderer.material = m;
}
but, there's no warranty your planes will be in desired order... you have to make sure, that this loop goes thru GameObjects in right way for you...
O$$anonymous$$, so no way I'm going to make this thing work...
Your answer
Follow this Question
Related Questions
Collision Detection with edges of planes 1 Answer
Multiple AR tracker not working. 0 Answers
Creating planes in Unity 1 Answer
Cloud recognition in Vuforia 0 Answers