JJ SHIMA Blog

二児のパパがゲーム開発アレコレを書いているブログ。Unity / UE / Scratch / プログラミングゼミ / プログラミング教育

【Unity】Could not produce class with ID 363 エラー

Unityでアセットバンドルを使用している際に、アセットバンドル側でしか使用していないコードが、IL2CPPビルド時に削除されてしまう場合があります。(Strip Engine Code)

Could not produce class with ID XXX

これを回避するためにはlink.xmlファイルを作り、
その中に含めたいコードを明示的に記載しておくのが対応方法の1つです。

[link.xml]
<linker>
       <assembly fullname="UnityEngine">
               <type fullname="UnityEngine.GameObject" preserve="all"/>
               <type fullname="UnityEngine.Texture2D" preserve="all"/>
       </assembly>
</linker>


本来ならlink.xmlに記載すれば良いように思いますが、
Could not produce class with ID 363
のエラーではlink.xmlに記載では治りませんでした。

ID 363とは

エラーメッセージ中のID xxx はUnity側のクラスIDを示しています。

クラス (ID 番号順) - Unity マニュアル

ID363はOcclusionCullingDataです。


対応方法
Unityフォーラムでも同様の報告がされています。

How to prevent stripping OcclusionCullingData type when using IL2CPP? - Unity Forum

 

The link.xml file won't work in this case. It is used to preserve managed code, but OcclusionCulling is a native code engine type.  

「OcclusionCullingはネイティブコードのためlink.xmlは機能しません」

 

I found that adding very small scene (1 renderer + OC) to client can solve this issue.

「アプリ内に1レンダラー+OcclusionCullingをONにしたシーンを含めてしまえば解決されます」

記載の通り、
CubeにRenderer+ OcclusionCullingにチェックをつけたシーンをアプリに含めるようにしたら解決しました。(画像のシーンです)

link.xmlに記載で解決できなかったのは初めてでした。
同様にID363エラーが出た場合は参考にしてみてください。