Search code examples
unity-game-engineunityscript

Unity Change Canvas Size as Portrait (mobile size)


How to change the canvas default scale (landscape) to portrait / match with mobile view? Thank you


Solution

  • Use the line below whenever you need.

        Screen.orientation = ScreenOrientation.Portrait;
    

    Changing display orientation doesn't depend on Canvas but Canvas changes upon display orientation. So when orientation changes, canvas orientation does same.

    Be aware of using UI components in a way so that it doesn't look bad when display orientation changes.