- Home /
My canvas recttransform.rect.height don't change properly
Hi, I have a Canvas where my UI belongs in.
I get the canvas recttransform like this : canvasRectTransform = canvas.transform as RectTransform;
Inside i have a panel whose position depends on the canvasRectTransform .rect.width.
My issue is that when i play my game in editor and change my game resolution (with the mouse i scale the view window of the game) to reduce its height (eg having a landscape mode), my canvasRectTransform.rect.height don't change accordingly !!! (Stay at 600) Instead it is the width that changes (increasing values) ?!
It is not what I want : if i reduce/increase the screen height, the canvasRectTransform.rect.width should stay the same and the canvasRectTransform.rect.height should change accordingly.
How can you explain this behavior and how to correct it ?
Thanks for any help.
Answer by el_trex · Aug 11, 2017 at 05:31 PM
I have to add something since i suspect it is related : In my canvas Scaler module, the Screen match mode is set to Expand as it adjust the UI both vertically and horizontally as i change width or height of the game window.
Your answer

Follow this Question
Related Questions
Rect to RectTransform on overlay Canvas? 1 Answer
Canvas lines showing at run time 2 Answers
Click targets for UI elements ignore Pos Z? 0 Answers
How to align pixel art with UI system ? 0 Answers