- Home /
Is there a clipping distance for UI elements?
I have some UI elements that are in front of our canvas instead of exactly on it. But at a certain distance from the canvas they are sliced and no longer rendered, just as if they had reached a camera's near clipping plane. The strange thing is that I am using a screen space overlay canvas so no camera is used. I've even tried changing the camera's clipping planes just in case, but it makes no difference.
It's confusing because I don't see this issue in the editor, only in Android builds. This problem arose after we upgraded from Unity 5.3 to 5.6.
If this is a clipping issue how can I change the distance, or at least see what the maximum allowed distance is?
Answer by The-Scripter · Nov 02, 2017 at 03:08 PM
I have found out through experimentation that UI elements are rendered when their Z position is between -1000 and 1000. This is plenty of space, except the distance depends on canvas scaling. So on my high-res device the canvas scale is 2, and the draw distance is reduced to -500 to 500.
I made this an answer. I see no reason for you not to accept it.
Whether objects fit within the clipping distance depends on the canvas scaling, and the canvas scaling depends on the resolution of the screen that the game is running on. If the clip distance can't be changed then you never know whether canvas elements will be visible on any device. If I can't find a solution I'll file a bug report.
Your answer
Follow this Question
Related Questions
SetPropertyBlock for CanvasRenderer? 1 Answer
How to Render Unity UI Canvas in between two 3D Objects? 0 Answers
RectMask2D.RemoveClippable(IClippable clippable) doesn't seem to work. Am I using it correctly? 2 Answers
Display a world-space canvas to overlay all the meshes but not the other UI objects 0 Answers
World space selection box 0 Answers