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

前端 未结 6 1258
梦毁少年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:30

    A easy way to do this is considering your target, I mean if you're doing a game for Iphone 5 then the aspect ratio is 9:16 v or 16:9 h.

       public float targetRatio = 9f/16f; //The aspect ratio you did for the game.
    void Start()
    {
       Camera cam = GetComponent();
       cam.aspect = targetRatio;
    } 
    

提交回复
热议问题