简体   繁体   English

独立播放器的外观与游戏视图不同

[英]Standalone Player Looks Different than Game View

Okay so I've built this little dodger game and everything is perfect except the standalone player doesn't match the game view visually. 好的,所以我已经构建了这个小躲闪游戏,除了独立玩家在视觉上与游戏视图不符之外,其他一切都很完美。 Pics for reference. 图片供参考。 Please let me know anything to stop this issue. 请让我知道任何阻止该问题的信息。

I want the standalone player to be the same as the game view. 我希望独立播放器与游戏视图相同。

Changing the resolution in the player settings doesn't work so far. 到目前为止,在播放器设置中更改分辨率无效。

Unity GameView Unity GameView Unity GameView,

Standalone Player 独立播放器 独立播放器

Looks to me like its your scale settings in the Game window. 在我看来,它是您在“游戏”窗口中的scale设置。 It's set at 0.33 in the picture you've posted. 在您发布的图片中将其设置为0.33。

Try changing your view to Free Aspect , then adjust your camera GameObject to tighten in on your gameplay area. 尝试将视图更改为Free Aspect ,然后调整相机GameObject以收紧游戏区域。 Or just refresh your layout, sometimes changing the aspect ratio while the Game view is smaller makes it difficult to restore the aspect you are looking for. 或只是刷新您的布局,有时会在“游戏”视图较小时更改纵横比,因此很难恢复您要寻找的纵横比。

Reset your layout here: 在此处重置布局:

Window\\Layouts\\Default (or whatever you prefer) 窗口\\布局\\默认(或您喜欢的任何内容)

I used this code, with two different cameras rendering. 我用这个代码,有两个不同的相机渲染。

void Update () 

{ {
float targetaspect = 4f / 3f; 浮targetaspect = 4F / 3F; // set the desired aspect ratio float windowaspect = (float)Screen.width / (float)Screen.height; //设置所需的纵横比浮windowaspect =(浮点)Screen.width /(浮点)Screen.height; // determine the current aspect ratio float scaleheight = windowaspect / targetaspect; //确定当前纵横比浮法scaleheight = windowaspect / targetaspect; // current viewport height should be scaled by this amount //当前视口的高度应该量进行缩放

// 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;
}

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM