MRTK とマネージド コードの削除 — MRTK2

Unity の IL2CPP スクリプト バックエンド (Unity 2018.4 ではオプション、2019 以降では必須) を使用すると、マネージド コードが削除されます。 Unity のリンカーでは、このプロセスを実行することでバイナリ サイズを減らすと共に、ビルド時間を短縮します。

Mixed Reality ツールキットでは、ファイル link.xml を使用して Unity のリンカーによる MRTK アセンブリの処理方法を制御します。 このファイル (Unity のドキュメントに詳しい説明があります) は、その使用方法を推測できない場合 (たとえば、リフレクションを通じて使用するなど) に、リンカーにコードの保持方法に関する指示を与えます。

柔軟でカスタマイズ可能なプラットフォームとして、MRTK ではインポート時に link.xml ファイルを Assets/MixedRealityToolkit.Generated に作成します (存在しないとわかった場合)。 既存の link.xml ファイルは上書きされません。 link.xmllink.xml.meta をバージョン管理に追加することをお勧めします。 開発者はプロジェクトのニーズに合わせて Assets/MixedRealityToolkit.Generated/link.xml を自由にカスタマイズできます。

既定では、MRTK によって作成された link.xml ファイルには、次のデータに示されているアセンブリ全体が保持されます。

<linker> 
  <!-- 
    This link.xml file is provided to prevent MRTK code from being optimized away 
    during IL2CPP builds.More details on when this is needed and why this is needed 
    can be found here: https://github.com/microsoft/MixedRealityToolkit-Unity/issues/5273 
    If your application doesn't use some specific services (for example, if teleportation system is 
    disabled in the profile), it is possible to remove their corresponding lines down 
    below(in the previous example, we would remove the TeleportSystem below). 
    It's recommended to start with this list and narrow down if you want to ensure 
    specific bits of code get optimized away. 
  --> 
  <assembly fullname = "Microsoft.MixedReality.Toolkit" preserve="all"/> 
  <assembly fullname = "Microsoft.MixedReality.Toolkit.SDK" preserve="all"/> 
  <!-- Core systems --> 
  <assembly fullname = "Microsoft.MixedReality.Toolkit.Services.BoundarySystem" preserve="all"/> 
  <assembly fullname = "Microsoft.MixedReality.Toolkit.Services.CameraSystem" preserve="all"/> 
  <assembly fullname = "Microsoft.MixedReality.Toolkit.Services.DiagnosticsSystem" preserve="all"/> 
  <assembly fullname = "Microsoft.MixedReality.Toolkit.Services.InputSystem" preserve="all"/> 
  <assembly fullname = "Microsoft.MixedReality.Toolkit.Services.SceneSystem" preserve="all"/> 
  <assembly fullname = "Microsoft.MixedReality.Toolkit.Services.SpatialAwarenessSystem" preserve="all"/> 
  <assembly fullname = "Microsoft.MixedReality.Toolkit.Services.TeleportSystem" preserve="all"/> 
  <!-- Data providers --> 
  <assembly fullname = "Microsoft.MixedReality.Toolkit.Providers.LeapMotion" preserve="all"/> 
  <assembly fullname = "Microsoft.MixedReality.Toolkit.Providers.OpenVR" preserve="all"/> 
  <assembly fullname = "Microsoft.MixedReality.Toolkit.Providers.UnityAR" preserve="all"/> 
  <assembly fullname = "Microsoft.MixedReality.Toolkit.Providers.WindowsMixedReality.Shared" preserve="all"/> 
  <assembly fullname = "Microsoft.MixedReality.Toolkit.Providers.WindowsMixedReality" preserve="all"/> 
  <assembly fullname = "Microsoft.MixedReality.Toolkit.Providers.XRSDK.WindowsMixedReality" preserve="all"/> 
  <assembly fullname = "Microsoft.MixedReality.Toolkit.Providers.WindowsVoiceInput" preserve="all"/> 
  <assembly fullname = "Microsoft.MixedReality.Toolkit.Providers.XRSDK" preserve="all"/> 
  <!-- Extension services --> 
  <assembly fullname = "Microsoft.MixedReality.Toolkit.Extensions.HandPhysics" preserve="all"/> 
  <assembly fullname = "Microsoft.MixedReality.Toolkit.Extensions.Tracking" preserve="all"/> 
  <assembly fullname = "Microsoft.MixedReality.Toolkit.Extensions.SceneTransitionService" preserve="all"/> 
</linker>

link.xml ファイル形式の詳細については、Unity のドキュメントを参照してください。

関連項目