通常对于Unity我在Illustrator中设计我的所有作品。所以我从1440x1920(用于肖像游戏)开始,并勾勒出1080x1920的红框。因此,适合1080x1920的所有内容通常都适合我的iOS设备系列。然后我为所有图像设置每单位像素数为192。这种方法对我很有帮助。既然iPhone X正在混合中,我怎么能以类似的方式迎合它?
答案 0 :(得分:3)
根据我的经验,你不必做很多事情,场景中的游戏对象会很合适,Unity已经为你做了这件事你可能需要做的唯一事情就是调整UI画布如果你正在使用UGUI,它也很容易,为什么?因为大多数手机具有相似的宽高比,在我们的团队中,我们会做这样的修复:
设计基于1080p(1080x1920)的所有UI内容(720p也很好,但我们假设将来会有更多的1080p设备)
将以下脚本附加到所有画布以进行自动修复:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CanvasScreenAutoFix : MonoBehaviour
{
public static CanvasScreenAutoFix instance;
private static float DEPEND_W = 1080;
private static float DEPEND_H = 1920;
public float scaleRatio = 1.0f;
private void ResizeCanvas()
{
int screenW = Screen.width;
int screenH = Screen.height;
if (DEPEND_W == screenW && DEPEND_H == screenH)
{
scaleRatio = 1.0f;
return;
}
else
{
float W_scale = screenW / (float)DEPEND_W;
float H_scale = screenH / (float)DEPEND_H;
float scale = W_scale < H_scale ? W_scale : H_scale;
GetComponent<CanvasScaler>().scaleFactor = scale;
scaleRatio = scale;
}
}
private void Awake()
{
ResizeCanvas();
if(instance == null)
{
instance = this;
}
}
}
结果变得相当不错,实际上,在此之后我们不再需要关心iPhone系列的尺寸问题(iphone4可能存在一些问题,因为它们具有不同的宽高比,但由于很少有设备......)。