Reputation: 5119
I have two camera. One which is the main camera and another that follow an object.
The main camera is attached to a canvas with HUD and other GUI Text stuff. When I change the camera to the object that need to be followed, I loose the canvas. I clearly need to change the Render Camera inside the Canvas component.
I've tought that something like this would exist
canvas.GetComponent<Canvas>().renderCamera...
but it's not. So how can I change the render camera via script?
Upvotes: 2
Views: 8690
Reputation: 1897
Assign to the Canvas.worldCamera
Doesn't make sense but that's the way it is!
Upvotes: 1
Reputation: 4870
I think it's this one:
https://docs.unity3d.com/ScriptReference/Canvas-worldCamera.html
canvas.worldCamera = someOtherCamera;
Upvotes: 2