My game has a typing cursor that is instantiated based on the location of each letter in a string. Here is that code:

 public void UpdateCursorPosition()
        Vector2 nextLetter = tm.quoteOutput.transform.TransformPoint(NextCharPosition());
        Vector2 cursorPosition = new(nextLetter.x - currentCursor.Item2.x, nextLetter.y - currentCursor.Item2.y);
        currentCursor.Item1.transform.position = cursorPosition;

    private Vector2 NextCharPosition()
        float x = tm.quoteOutput.textInfo.characterInfo[tm.quoteIndex].origin;
        float y = tm.quoteOutput.textInfo.characterInfo[tm.quoteIndex].baseLine;

        return new Vector2(x, y);

These work perfectly with Screen Space - Overlay selected, but to use Post Processing we had to switch to Screen Space - Camera, and when we switch to this, the cursor is rendered in the wrong place.

Here are gifs to show you what I mean:

Cursor Position in Screeen Space - Camera Cursor Position in Screen Space - Camera

Cursor Position in Screeen Space - Overlay

Cursor position in Screen Space - Overlay

As you can see, in the Camera Render mode, the cursor appears over the letters, as is intended. In Overlay render mode, however, the cursor renders below the game space.

  • \$\begingroup\$ It's unusual to position a UI element with transform.position rather than RectTransform.anchoredPosition. To reproduce this problem and test solutions, we'll need more details about how the UI hierarchy is set up. Try to create a Minimal Complete Verifiable Example: make a new, empty project, and add just the bare minimum objects and scripts to it to demonstrate the positioning problem. Then edit your question to list every single step and every line of code required to build that minimal example. \$\endgroup\$
    – DMGregory
    Jul 12 at 20:08


You must log in to answer this question.

Browse other questions tagged .