• RuntimesUnity
  • 關於合成紋理時出現 Graphics.CopyTexture

您好我目前是輸出的平台是Unity Webgl
在編輯模式下 合成紋理的時候會出現此錯誤
Graphics.CopyTexture called with incompatible formats (src=RGBA Compressed ASTC6X6 UNorm, dst=s).
但輸出後是使用網頁看或是行動裝置上的網頁都是正常的。

設定中Texture compression formats我選的Format是ASTC 6x6
主要是因為行動裝置的Web瀏覽器支援這個格式,
但在編輯模式下spine會呈現灰色透明方塊狀,
並出現
Graphics.CopyTexture called with incompatible formats (src=RGBA Compressed ASTC6X6 UNorm, dst=s).

1.想請問的是有沒有格式能同時支援行動裝置與編輯模式,
或是有其他方法能克服這個問題。

2.說明文件中有提到要將Compression設置為None
但我選擇了ASTC6X6是不是意味著這張圖會壓縮,
但合成紋理在手機上表現很良好

Related Discussions
...

您好,

針對您在Unity WebGL平台上合成紋理時出現的錯誤訊息 "Graphics.CopyTexture called with incompatible formats (src=RGBA Compressed ASTC6X6 UNorm, dst=s)",這是因為在編輯模式下,Unity無法直接從壓縮的ASTC格式紋理中讀取數據。

  1. 格式支援問題

    • 在編輯模式下,您可以考慮使用未壓縮的格式來避免這個問題。這樣可以確保在編輯模式下不會出現灰色透明方塊的情況。您可以在編輯模式下將紋理的壓縮格式設置為None,然後在構建時再切換回ASTC格式。
    • 另一個方法是使用ETC2格式,這個格式在大多數行動裝置上也有良好的支援,但同樣需要在編輯模式下進行測試以確保兼容性。
  2. Compression設置

    • 是的,選擇ASTC6X6意味著這張圖會被壓縮。雖然在行動裝置上表現良好,但在編輯模式下可能會出現問題。根據這篇討論,ASTC格式在某些舊設備上可能不被支援,Unity會在運行時解壓縮這些紋理並使用未壓縮的32位格式。
    • 您可以參考這裡的建議,將Compression設置為None來避免在編輯模式下的問題。

總結來說,您可以在編輯模式下使用未壓縮的格式,並在構建時切換回ASTC格式,這樣可以確保在編輯模式和行動裝置上都能正常顯示。

    Spinebot
    謝謝你的回答
    不過因為圖片眾多,不太可能每次這樣來回切換格式,不太方便,
    另外我想問的是說假設,不用ASTC格式,是用Unity預設的格式,
    如果這樣做會跳出
    RGBA Compressed ASTC6X6 UNorm format is not supported, decompressing texture
    的警告,
    這樣會導致手機瀏覽器因為沒有壓縮圖片,記憶體溢出嗎?

      tony020409 不過因為圖片眾多,不太可能每次這樣來回切換格式,不太方便,

      You would not switch texture formats manually but via pre-build and post-build steps:
      https://docs.unity3d.com/ScriptReference/Build.IPreprocessBuildWithReport.OnPreprocessBuild.html
      https://docs.unity3d.com/ScriptReference/Build.IPostprocessBuildWithReport.OnPostprocessBuild.html

      In general if a compressed format is not supported, it will be decompressed on the target device, leading to increased memory consumption. This means that in VRAM the uncompressed texture size needs to be stored instead of the compressed texture size. I would hwoever assume that Unity decompresses textures one-by-one and not store both the compressed and uncompressed textures side-by-side. So you could perform some size-tests with just the uncompressed textures to see how much VRAM it likely requries on the target device if the device does not support the compression format.

        Harald
        如果我的圖片是透過Addressable去打包的,
        那也是透過IPreprocessBuildWithReport.OnPreprocessBuild去處理嗎?

        @tony020409 Please note that general Unity questions are better asked on the Unity forum. I'm not entirely sure, but IIRC IPreprocessBuildWithReport.OnPreprocessBuild is called when you build addressable bundles during your build, but this callback is not issued when building the bundle alone (via the Addressables panel). I'm not sure there is any callback available when building addressables alone, but better ask on the Unity forum, or ask chatgpt.

        You could however create your own build scripts and build the addressables from there, then you have full control and could issue your own callbacks.