独立播放器看起来与游戏视图不同

时间:2018-02-14 03:24:20

标签: unity3d view unity5

好吧所以我已经建立了这个小小的道奇游戏,除了独立玩家在视觉上与游戏视图不匹配外,一切都很完美。图片供参考。请让我知道任何事情来阻止这个问题。

我希望独立播放器与游戏视图相同。

到目前为止,更改播放器设置中的分辨率无效。

Unity GameView Unity GameView,

独立播放器 Standalone Player

2 个答案:

答案 0 :(得分:0)

在我看来,它就像是游戏窗口中的scale设置。在您发布的图片中,它设置为0.33。

尝试将视图更改为Free Aspect,然后调整相机GameObject以加强游戏区域。或者只是刷新你的布局,有时在游戏视图较小时改变宽高比会使你很难恢复你正在寻找的方面。

在此处重置您的布局:

Window \ Layouts \ Default(或您喜欢的任何内容)

答案 1 :(得分:0)

我使用此代码,使用两个不同的相机渲染。

void Update () 

{
    float targetaspect = 4f / 3f; //设置所需的宽高比     float windowaspect =(float)Screen.width /(float)Screen.height; //确定当前的宽高比     float scaleheight = windowaspect / targetaspect; //当前视口高度应按此数量缩放

// obtain camera component so we can modify its viewport
Camera camera = GetComponent<Camera>();

// if scaled height is less than current height, add letterbox
if (scaleheight < 1.0f)
{  
    Rect rect = camera.rect;

    rect.width = 1.0f;
    rect.height = scaleheight;
    rect.x = 0;
    rect.y = (1.0f - scaleheight) / 2.0f;

    camera.rect = rect;
}
else // add pillarbox
{
    float scalewidth = 1.0f / scaleheight;

    Rect rect = camera.rect;

    rect.width = scalewidth;
    rect.height = 1.0f;
    rect.x = (1.0f - scalewidth) / 2.0f;
    rect.y = 0;

    camera.rect = rect;
}

}

相关问题