1
\$\begingroup\$

I know how to do It on one, but I don't know how to do it using multiple cameras, 3 of them are important, i want to show the whole UI except for the minimap. I need to change the camera angle on some spots, while keeping the same canvas for displaying the number of coins XP and the current level.

\$\endgroup\$
1
  • \$\begingroup\$ Set the cameras as the main-camera when changing into them, through script? \$\endgroup\$ Dec 20, 2017 at 21:53

2 Answers 2

1
\$\begingroup\$

Option 1:

Set the canvas to be a Screen Space - Overlay

This mode means that the canvas renders last directly to the screen (in screen space), regardless of which cameras are active and how they're displaying what they display.

Option 2:

Set the canvas to be a Screen Space - Camera and change which camera it renders on when appropriate.

This mode means that the canvas is the last thing rendered by the indicated camera and will only render on that camera's view (and if another camera renders afterwards, it will render over the canvas). By changing which camera is active you also change which camera the canvas renders to, you maintain the visibility of the canvas.

Option 1 is likely the preferred solution, but depending on your exact needs and camera setup, Option 2 might be what you're looking for.

\$\endgroup\$
1
  • \$\begingroup\$ Not actually how SSC works, at least not in current version Unity. It actually puts the canvas on a plane in front of the camera, which can in case environment clipping. It is possible to configure to only exist epsilon away from the ncp, but artifacts can persist; especially with very fast-moving or erratic cameras. \$\endgroup\$
    – Weckar E.
    Nov 29, 2020 at 21:57
1
\$\begingroup\$

Here is a simple solution: duplicate another canvas then set this canvas to new camera.
You could use this simple script to read the raw_image texture from the target canvas:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;


public class CameraTexture : MonoBehaviour
{
    public RawImage camera_texture;
    private RawImage rawImage;
    // Start is called before the first frame update
    void Start()
    {
        rawImage = GetComponent<RawImage>();
    }

    // Update is called once per frame
    void Update()
    {
        rawImage.texture = camera_texture.texture;
    }
}
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .