I have created a rendering texture named: GUICameraRenderTexture
Here is a screenshot of the Player camera:
I've assigned to the target texture the new GUICameraRenderTexture:
Then at the bottom of the hierarchy, I have a main menu> Camera:
The new camera, I changed the clear flags to not erase and hide the mask for nothing:
Then there is a canvas whose rendering mode is set to Screen Space – Overlay
And finally the Raw image that I've assigned to the texture, the GUICameraRenderTexture:
I want to start the game with the player's camera, then the Escape key to go to the main menu of the camera.
Screen capture if I disable the main menu camera mistletoe:
Then I added a script to the Main Menu object:
public class Switch : MonoBehaviour
public GameObject() cameras;
public RenderTexture guiCameraRenderTexture;
// Start is called before the first frame update
// Update is called once per frame
var cam0 = cameras(0).GetComponent();
cam0.targetTexture = guiCameraRenderTexture;
In the editor, I have disabled the new main menu's graphics camera and its functions, and enabled the player's video camera without the GUICameraRenderTexture, the target texture is zero at startup.
When I press the Esc key when the game is running, it displays the preview camera, but also the player's camera and not the main menu camera:
On the escape key, the main menu should appear as in the first screen capture. If I make the changes by removing the target texture and activating the graphics camera, it will work, but using the script will not work.
It shows the player's camera on both the preview (rawimage) and on the mistletoe camera.
The goal is to make sure that the key escapes to go to the main menu. The camera's main menu of the GUI must be black and the player's camera must be displayed in the raw preview.