MRTK e rimozione del codice gestito - MRTK2

Quando si usa il back-end di script IL2CPP di Unity (facoltativo in Unity 2018.4, richiesto nel 2019 e versioni successive), si verifica la rimozione del codice gestito . Il linker di Unity esegue questo processo per ridurre le dimensioni binarie e ridurre i tempi di compilazione.

Il Realtà mista Toolkit usa un file, link.xml, per influenzare il modo in cui il linker di Unity elabora gli assembly MRTK. Questo file, descritto in dettaglio nella documentazione di Unity, fornisce al linker istruzioni su come conservare il codice quando l'utilizzo non può essere dedotto (ad esempio usato tramite reflection).

Come piattaforma flessibile e personalizzabile, MRTK crea il link.xml file in su Assets/MixedRealityToolkit.Generated importazione, se non esiste. I file di link.xml preesistenti non vengono sovrascritti. È consigliabile link.xml aggiungere e link.xml.meta aggiungere al controllo della versione. Gli sviluppatori devono essere liberi di personalizzare Assets/MixedRealityToolkit.Generated/link.xml per soddisfare le esigenze del progetto.

Per impostazione predefinita, il file link.xml creato da MRTK mantiene l'intera quantità di assembly illustrati nei dati seguenti.

<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>

Per altre informazioni sul formato di file link.xml, vedere la documentazione di Unity.

Vedi anche