- Home /
Unity 4.6 Canvas Dynamic Scale
Hi everyone,
I am really excited about new UI and I am trying lots of things. Now, I am trying to do seamless transition between "scenes". A "scene" is transitioned to, by moving camera around. On nearly every my "scene", there is UI Canvas. These must be in world space render mode (I want them to stay in "scene" after camera moves elsewhere).
I am now using orthographic camera for my 2D game and setting orthographic size according resolution and ratio. Problem is, that I don't know how to scale down canvases to the size of camera. One solution is, that I will dynamically change canvas to "screen space camera", read scaled values, store them, set canvas back to "world space" and apply stored values. Problem is, that I don't know how to access these values.
So the question is: How can I access calculated values inside RectTransform component?
Is there any other way of doing this?
Try adding Reference resolution in your Canvas. Set you reference resolution and put your Canvas objects where you want. Go to Game and check multiple resolutions.
Answer by cuchi · Sep 16, 2014 at 08:29 PM
If anyone is interested, I have found a solution to this: If you set canvas to Screen Space - Camera render mode and attach camera to it, then, if you switch it to World Space render mode, calculated values will stay in place, so no extra logic is needed. I can't believe I haven't discovered that earlier :)
This is probably the brilliantest thing I've ever seen. You're a flipping genius. If I could give you a cookie, I would.
This is the answer I was searching for, but couldn't find for the longest time because I didn't know what to search for. You're right, it is the brilliantest thing.
If anyone is still facing some issue about the same even after doing this, maybe you should try to use the Anchor Points and Canvas Scaler on the Canvas.. Here is an excellent article about the same Canvas Scaler Unity 4.6
Thanks Falconer, this addressed the SCALER: Scale to screen size, but what I have been stumped for a week on using the "$$anonymous$$eep pixel size" scaler =(
Answer by gegagome · Jan 20, 2015 at 08:46 AM
Love it!!
I messed up my canvas local scale and this solution even improved my rectTransform AnchoredPos for a panel
Thanks
Your answer
![](https://koobas.hobune.stream/wayback/20220613163046im_/https://answers.unity.com/themes/thub/images/avi.jpg)