sprite的大小 unity_[Unity]SpriteShape与atlas的小坑
現象
今天打Android包發現場景中有幾處2D地形顯示不正常,查看后發現是此處用了SpriteShape做了可編輯的地形。然后在Editor模式里用bundle模式跑了一下,發現在SpriteShape的源碼里有報錯,初步感覺會比較好查。
死路
然后直接拿著報錯搜了一下,找到了兩篇帖子: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
大意就是他們做了點更新,可以在Inspector里直接顯示不符合規范的配置,而不是等出了包報錯或crash(之前還確實遇到過crash的情況。。)。
然后更新到最新版的SpriteShape,發現確實有個warning,說我的texture不是Full Rect的,修改以后,還是報錯。
然后去問了一圈同事,有個大佬說texture需要是repeat的,檢查一下發現確實不是repeat,修改以后,依然不行。。
瞎搞
那只能去看報錯的源碼了,還好比較容易懂,大概就是拿貼圖的時候沒有拿到。那就看這個貼圖有什么特殊的地方,然后發現它在atlas里。
然后對atlas配置一頓亂改,改大小改翻轉改XX,依然拿不到。
所以最后只能把這種貼圖從atlas里拿出來了。
然后還真的好了,能找到了。。
官方還真說過。。
當然最后還是去繼續搜了一下,發現在之前一個介紹Sprite Shape的官方博客里,確實說過一段不能放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 ワールドを構築しよう - Unity Technologies Blog?blogs.unity3d.com
然后這件事情,在官方的文檔里也沒有被提過,就那么靜靜的留了個坑給你。。
總結
以上是生活随笔為你收集整理的sprite的大小 unity_[Unity]SpriteShape与atlas的小坑的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ios保存gif到相册_iOS相册中的G
- 下一篇: python 去除列表空值_零基础学习P