Search Issue Tracker

Fixed in 2021.2.X

Fixed in 2020.3.X, 2021.1.X



Found in






Issue ID




[IL2CPP] Vector-Graphics BuildSprite fails when using IL2CPP backend



Reproduction steps:
1. Open user attached Project
2. Build the SampleScene with IL2CPP
3. Open the Build

Expected result: A Vector sprite is drawn on the screen
Actual result: An empty scene is loaded

Reproducible with: 2020.2.0a20, 2020.3.5f1, 2021.1.4f1, 2021.2.0a14
Not reproducible with: 2019.4.24f1, 2020.2.0a19

  1. Resolution Note (fix version 2021.2):

    Fixed in 2022.1.0a1

  2. Resolution Note (fix version 2021.2):

    Fixed in 2021.2.0b7

  3. Resolution Note (fix version 2021.1):

    Fixed in 2021.1.14f1

  4. Resolution Note (fix version 2020.3):

    Fixed in 2020.3.14f1
    Fix managed code stripping issue due to reflection in com.unity.vectorgraphics.

Comments (1)

  1. lukasv88

    Apr 29, 2021 10:59

    This issue is caused by reflection inside the BuildSprite method:

    // The Sprite.Create(Rect, Vector2, float, Texture2D) method is internal. Using reflection
    // until it becomes public.
    var spriteCreateMethod = typeof(Sprite).GetMethod("Create", BindingFlags.Static | BindingFlags.NonPublic, Type.DefaultBinder, new Type[] { typeof(Rect), typeof(Vector2), typeof(float), typeof(Texture2D) }, null);
    var sprite = spriteCreateMethod.Invoke(null, new object[] { rect, pivot, svgPixelsPerUnit, texture }) as Sprite;

    Sprite is located in UnityEngine.CoreModule and we were able to work around the issue for now by adding <assembly fullname="UnityEngine.CoreModule" preserve="all"/> into link.xml.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.