How can I code my game to work on every resolution of Android devices? (with Unity)

前端 未结 6 1249
梦毁少年i
梦毁少年i 2021-01-30 19:12

I have a game what I made in 480x320 resolution (I have set it in the build settings) in Unity. But I would like to publish my game for every Android device with every resolutio

6条回答
  •  隐瞒了意图╮
    2021-01-30 19:35

    The way i did is to change camera viewport according to device aspect ratio Consider you made the game for 800x1280

    The you can do this in any one of the script

    float xFactor = Screen.width / 800f;
    float yFactor = Screen.height  / 1280f;
    
    
    Camera.main.rect=new Rect(0,0,1,xFactor/yFactor);
    

    and this works like magic

提交回复
热议问题