- Home /
'ScreenSpace-Camera' canvas: camera set at runtime doesn't update scale
Hey folks,
So I've got a Screen-SpaceCamera canvas whose camera exists in a previously loaded scene. Inside the awake of my UI scripts, I call:
m_Canvas.worldCamera = Station.WorldCamera;
I've tried adding calls to set the renderMode, turn it on and off, waiting until Start, and for whatever reason, the scale of the canvas is never corrected. So, when I run on device (iOS and Android), the canvas is super tiny.
It takes input correctly, but just refuses to resize itself. Does anyone have any idea how to get around this?
Thanks! -Matt
for a screen space canvas you should not have to do anything for this to work, it just works. you don't need to assign a camera either. what you can try this call https://docs.unity3d.com/2018.2/Documentation/ScriptReference/Canvas.ForceUpdateCanvases.html
Hey thanks for the reply.
I just took a look at my question and realized I mistyped a few things. The canvas is set to SCREEN-SPACE CA$$anonymous$$ERA, so it does need the camera to deter$$anonymous$$e it's scale. I tried calling Canvas.ForceUpdateCanvases and nothing happened. I also added a few buttons I could click at runtime to try to make adjustments (like setting the camera, calling force update, etc) and NOTHING seems to fix it. The scale of the canvas just will NOT fix itself.
Inside my scene while editing (not in play mode), I can drag my prefab into the scene (the one with the cameras that is loaded previously) and assign the camera, and the canvas will fix itself. But for some unknown reason, it will not do it at runtime.
Your answer
