- Home /
Is there a way to render models over the UI
i have VR scene, where i have a cube inside a canvas with render mode ->World space
I need to rotate the cube (or any other mesh) that cube over the UI.
One issue i am facing is the mesh and UI are going inside each other.
There are two solution that i can think of now is
1)Move the cube in z axis but that cant be done as it can be any model which means it can have different height and length.
2) Use Two camera and use layer and culling mask
but i want to avoid both the solution,Now what can be done to fix this issue i just want that object to be rendered above the UI even if both ui and object are at same position
You could try setting the render queue on either your object or the UI. https://docs.unity3d.com/ScriptReference/$$anonymous$$aterial-renderQueue.html
Answer by xxmariofer · Feb 13, 2019 at 08:42 AM
hello, can you test using change the render mode to screen space - camera? that will make the canvas to scale to always fit the camera size and you can adjust the plane distance for making sure its always behind.
We need click on those UI so we can not go for screen space as it will not take the click in vr .I know for mesh we have some shader that will make object render on top of any other mesh even if that mesh is inside any other mesh.Hoping something like i can find for UI also
oh i see, i have never worked with vr so wasnt thinking of that posibility. may i ask why not go with your first approach of offsetting the object? you say that multiple objects can be inside the canvas, but you can offset it dynamically, since you can access the (for this example) boxcollider, and access the boxcollider.size, and offessting for example the boxcollider.size
float offset = boxObject.GetComponent<>().size.z / 2;
canvasPosition += new Vector3(0,0, offset);
if the objects doesnt have collider you can access the renderer component and the bounds property that has $$anonymous$$ and max subpropertys that will give you the max and $$anonymous$$ point of the renderer
Your answer
Follow this Question
Related Questions
Double Screen Camera (VR , Cardboard vision) Same Camera Side by Side 0 Answers
Google Cardboard Cannot See Reticle 1 Answer
Set Image or Sprite to not ReadPixel 0 Answers
Screen Space - Camera to Screen Space - Overlay switch issue 0 Answers
Canvas screenpspace overlay for a particular camera 0 Answers