sprite的大小 unity_[Unity]SpriteShape与atlas的小坑
現(xiàn)象
今天打Android包發(fā)現(xiàn)場景中有幾處2D地形顯示不正常,查看后發(fā)現(xiàn)是此處用了SpriteShape做了可編輯的地形。然后在Editor模式里用bundle模式跑了一下,發(fā)現(xiàn)在SpriteShape的源碼里有報(bào)錯(cuò),初步感覺會(huì)比較好查。
死路
然后直接拿著報(bào)錯(cuò)搜了一下,找到了兩篇帖子:https://answers.unity.com/questions/1725712/unity-2019312f1-new-project-build-nullreferenceexc.html?answers.unity.comhttps://forum.unity.com/threads/sprites-shapes-crash-on-android-build-v-2019-3-13.892567/?forum.unity.com
大意就是他們做了點(diǎn)更新,可以在Inspector里直接顯示不符合規(guī)范的配置,而不是等出了包報(bào)錯(cuò)或crash(之前還確實(shí)遇到過crash的情況。。)。
然后更新到最新版的SpriteShape,發(fā)現(xiàn)確實(shí)有個(gè)warning,說我的texture不是Full Rect的,修改以后,還是報(bào)錯(cuò)。
然后去問了一圈同事,有個(gè)大佬說texture需要是repeat的,檢查一下發(fā)現(xiàn)確實(shí)不是repeat,修改以后,依然不行。。
瞎搞
那只能去看報(bào)錯(cuò)的源碼了,還好比較容易懂,大概就是拿貼圖的時(shí)候沒有拿到。那就看這個(gè)貼圖有什么特殊的地方,然后發(fā)現(xiàn)它在atlas里。
然后對(duì)atlas配置一頓亂改,改大小改翻轉(zhuǎn)改XX,依然拿不到。
所以最后只能把這種貼圖從atlas里拿出來了。
然后還真的好了,能找到了。。
官方還真說過。。
當(dāng)然最后還是去繼續(xù)搜了一下,發(fā)現(xiàn)在之前一個(gè)介紹Sprite Shape的官方博客里,確實(shí)說過一段不能放atlas。。。There are several things to know about fill textures. First of all, they must be imported as individual files, and cannot be a part of a sprite atlas. Also, in the import settings, you have to make sure that the Wrap Mode is set to Repeat. If you fail to set the Wrap Mode correctly, the texture will create artifacts.Intro to 2D World Building with Sprite ShapeSprite Shape を使って 2D ワールドを構(gòu)築しよう - Unity Technologies Blog?blogs.unity3d.com
然后這件事情,在官方的文檔里也沒有被提過,就那么靜靜的留了個(gè)坑給你。。
總結(jié)
以上是生活随笔為你收集整理的sprite的大小 unity_[Unity]SpriteShape与atlas的小坑的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ios保存gif到相册_iOS相册中的G
- 下一篇: plc和pc串口通讯接线_Plc与pc串