Unity3D正确的相机正交尺寸 [英] Unity3D Correct Orthographic Size of Camera

查看:37
本文介绍了Unity3D正确的相机正交尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于 2D 游戏,默认相机(正交)大小为 5,我正在尝试找出获取原始图像视图的方法.应该是什么?因为 5 显示的图像比原始尺寸小很多.

For 2D game, default camera(orthographic) size is 5 and I am trying to figure out what it should be to get original views of images. What should it be? Because 5 shows the images very smaller than original size.

推荐答案

首先将相机变换缩放到 2/screenHeight,所以如果你有 1920x1080 的屏幕,它应该是 2/1080

First scale the cameras transform to 2/screenHeight, so if you have 1920x1080 screen it should be 2/1080

然后将您的相机地形尺寸设置为 1

Then set your cameras orographic size to 1

然后在精灵上,将像素到单位"设置为图像大小的高度,所以如果你有一个大小为 128x128 的图像,像素到单位应该是 128

Then on the sprite, set the "pixels to units" to the height of the image size, so if you have a image of size 128x128 the pixels to units should be 128

现在,如果您将精灵作为孩子放置到相机中,则对象的比例将以像素为单位.因此,如果您希望 128x128 大小的精灵在 1080 屏幕上为 128x128,只需将变换的比例设置为 128,128,0

Now if you place your sprite as a child to your camera, the scale of the object will be in pixels. so if you want a sprite of size 128x128 to be 128x128 on a 1080 screen just set the scale of the transform to 128,128,0

这样做的好处是,您可以为一种分辨率(如 1920x1080)设计游戏,而当您在具有另一种分辨率(相同纵横比)的屏幕上运行游戏时,您只需更改相机的 2/screenHeight 和只要纵横比相同,所有内容都将具有相同的相对大小,这将使其看起来相同.

The bonus of doing it this way is that you design the game for one resolution like 1920x1080 and when you run it on a screen with another resolution (same aspect ratio) you just need to change the 2/screenHeight for the camera and everything will have the same relative size which will make it look the same as long as the aspect ratio is the same.

这篇关于Unity3D正确的相机正交尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆