Search Unity

Is there a far clipping distance for UI elements?

Discussion in 'UGUI & TextMesh Pro' started by angel_m, Mar 24, 2020.

  1. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,160
    I have some UI elements in my game. The Canvas is Screen Space Overlay. I'm using Unity 2018 LTS, last version.
    The UI elements are not rendered-visible when far from Camera (about 1000) but my camera far clipping plane is set to 5000. The UI elements have not any layer assigned, so it is not a cull distance issue.
    I want the UI elements to be rendered and visible at any possible distance (camera far clipping plane).

    Any idea?
     
  2. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    If the canvas is really set to "screen space - overlay" everything inside should be rendered for sure. No camera is used for that mode, so it cannot be related to clipping distances.
     
  3. LuyangMoo

    LuyangMoo

    Joined:
    Jan 5, 2021
    Posts:
    1
    This is probably dead, but a work around that i found was to have the UI element move closer to the camera. (worldPointTransform = Transform component of the worldPoint) (If you only have a position, you will need to create a new Gameobject in game to make a Transform) =>

    Transform worldPointTransform;

    void Start()
    {
    worldPointTransform = new GameObject().transform;
    }


    Code (CSharp):
    1. worldPointTransform.LookAt(Camera.main.transform); //looks towards the camera, so the transform.forward is pointing towards the cam
    2.  
    3. worldPointTransform.position += worldPointTransform.forward * distanceDivider; //example, if distanceDivider = 2, the worldPoint is set to the halfway point from the camera to where it originally was