Unity3D校正相机的正交大小 [英] Unity3D Correct Orthographic Size of Camera

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

问题描述

对于2D游戏,默认的相机(正字)大小是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

将你的sprite作为孩子放置到你的相机,对象的比例将以像素为单位。所以如果你想要一个大小为128x128的sprite在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天全站免登陆