更改UI Image的sprite,保留宽高比已检查但无法正常工作吗? Unity 2019.1.0f2 [英] Changing UI Image's sprite, preserve aspect ratio is checked but not working? Unity 2019.1.0f2

查看:477
本文介绍了更改UI Image的sprite,保留宽高比已检查但无法正常工作吗? Unity 2019.1.0f2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在更改UI Image的sprite,保留纵横比,但无法使用.版本:Unity 2019.1.0f2

发生了什么

我已更新到Unity的最新软件更新,即Unity 2019.1.0f2.

I updated to the latest software update for Unity which is Unity 2019.1.0f2.

在版本为2018.3.12f之前,UI Image的精灵通常会更改.但是现在,当我更新它时,它并没有恢复其纵横比,而是被拉伸了.

Before when it was version 2018.3.12f, the UI Image's sprite changes normally. But now when I have updated it, it doesn't regain its aspect ratio and gets stretched.

当精灵在UI图像上更改时,图像的宽高比/宽度和高度会发生变化,当您返回原始图像时,它会被拉伸或压缩.

When the sprite changes on the UI image, the aspect ratio/width and height changes for the image and when you go back to the original image, then it becomes stretched or compressed.

我以为是因为我更新了游戏Unity版本,但我在一个全新的Unity项目中复制了它,并且它所做的完全相同.

I thought it was because I updated my game Unity version but I reproduced it on a brand new Unity project and it is doing the exact same thing.

我如何复制它:

Sprite []和图像中的代码.

Code in Sprite[] and Image.

用于将子画面图像更改为子画面数组中下一个图像的代码.

Code to change the sprite image to the next image in the sprite array.

有一个按钮可以循环显示图像.

Have a button to cycle through the images.

运行游戏.

多次按下按钮.

当它再次循环回到第一张图像时,它现在会被拉伸或压缩,并且长宽比不会恢复到其原始大小.

When it is cycled back to the first image again, it is now stretched or compressed and aspect ratio doesn't go back to its original size.

仅当我从2018.3.12f更新到最新版本的Unity 2019.1.0f2时才发生此错误.

This bug has only been happening when I updated to the latest version Unity 2019.1.0f2 from 2018.3.12f.

我们将不胜感激.谢谢!

Help would be appreciated. Thanks!

推荐答案

我遇到了同样的问题. 我发现了一个不好的解决方案,但它行得通:在更改sprite之前将null设置为sprite.

I had the same problem. I found a bad solution, but it works: set null to sprite before change sprite.

我认为这是由于以下原因造成的:

I think this is due to this: https://forum.unity.com/threads/use-sprite-mesh-option-recently-added-to-ui-image-what-is-this-for-exactly.604336/

这篇关于更改UI Image的sprite,保留宽高比已检查但无法正常工作吗? Unity 2019.1.0f2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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