Search Unity

BoxCollider2D not working on link.xml after switch to IL2CPP

Discussion in 'Editor & General Support' started by braintapgames, Sep 29, 2015.

  1. braintapgames

    braintapgames

    Joined:
    Mar 20, 2015
    Posts:
    8
    So I just made the switch from Mono 2x to IL2CPP due to Apple's requirement of a 64-bit version. My original version was working fine, but now that I'm using a link.xml, BoxCollider2D doesn't seem to work (via Set Property). What I'm trying to accomplish is enabling and disabling the Collider through triggers. The odd thing is that it works fine on Unity, but once it builds to an iOS device, it doesn't. Any help?

    Here is my current link.xml:

    <linker>
    <assembly fullname="UnityEngine">
    <type fullname="UnityEngine.SpriteRenderer" preserve="all" />
    <type fullname="UnityEngine.BoxCollider2D" preserve="all" />
    <type fullname="UnityEngine.Camera" preserve="all" />
    <type fullname="UnityEngine.GameObject" preserve="all" />
    <type fullname="UnityEngine.Canvas" preserve="all" />
    </assembly>
    <assembly fullname="UnityEngine.UI">
    <type fullname="UnityEngine.UI.Image" preserve="all" />
    <type fullname="UnityEngine.UI.Button" preserve="all" />
    <type fullname="UnityEngine.UI.Text" preserve="all" />
    </assembly>
    </linker>
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    @braintapgames

    Which version of Unity are you using? We had a bug related to this property which I believe was corrected in 5.0.1p1. I'm not sure though if this is a same problem, as we may be seeing something else here.
     
  3. braintapgames

    braintapgames

    Joined:
    Mar 20, 2015
    Posts:
    8
    @JoshPeterson

    I have tried it on both 5.0.1f1 and 5.2.1 with no luck.

    Just for a bit more info - I have tried it on both Xcode 6.3.1 and Xcode 7.
     
    Last edited: Sep 29, 2015
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    @braintapgames

    Can you try this with the Mono scripting backend locally? I wonder if it is a problem specific to IL2CPP? It seems to be different than the original issue we fixed. Also, what is the behavior your see which indicates this is not working? Is there an exception that occurs?
     
  5. braintapgames

    braintapgames

    Joined:
    Mar 20, 2015
    Posts:
    8
    @JoshPeterson

    My project was actually completely finished and in full working condition in Mono until I made the switch to IL2CPP.

    Certain triggers are supposed to turn BoxCollider2D off and on, but my player collides with everything (as if the BoxCollider2D is already triggered when it's not supposed to be) when it should be passing through. I am also attempting to enable and disable isTrigger, but that also is not working. Do I need to add anything to my link.xml to allow isTrigger to work on my BoxCollider2D?

    It works fine on my Unity, but does not work on my iPad Air or my iPhone 6.
     
    Last edited: Sep 29, 2015
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    @braintapgames

    Yes, this certainly looks like a different bug in IL2CPP. Can you submit a bug report with this project? We would like to correct it!
     
  7. braintapgames

    braintapgames

    Joined:
    Mar 20, 2015
    Posts:
    8
    I think the main issue lies with the isTrigger. Is there no known fix for that yet? And also, where do I submit the bug report?
     
  8. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    @braintapgames

    There is not a fix that I know of yet. You can submit a bug report via Help > Report a Bug in the editor. Please let me know the bug number when you submit it, and we will have a look at it.
     
  9. braintapgames

    braintapgames

    Joined:
    Mar 20, 2015
    Posts:
    8
    @JoshPeterson - I have reported the bug with a test scene. The bug number is #732822. I may have forgotten to include the link.xml, but if I did, the one posted here is the one I am currently using. Thanks again for your help!
     
  10. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    @braintapgames

    Thanks for reporting this bug, we will investigate it.
     
  11. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    We're facing the same thing within the PlayMaker Community

    <linker>
    <assemblyfullname="UnityEngine">
    <typefullname="UnityEngine.BoxCollider2D"preserve="all"/>
    </assembly>
    </linker>

    and that doesn't work when published on IOS, setting the .isTrigger via reflection simply fails without any errors, it just doesn't do anything.

    Since there is already a bug being reported, I won't create a new one, but it would be good to address it. I did test it both in Unity 4.7 and Unity 5.3.1 f1

    Thanks,

    Jean
     
  12. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    @Jean Fabre

    I think that you need one more entry in the link.xml file to make this work:

    <linker>
    <assembly fullname="UnityEngine">
    <type fullname="UnityEngine.BoxCollider2D" preserve="all"/>
    <type fullname="UnityEngine.Collider2D" preserve="all"/>
    </assembly>
    </linker>

    Please try this one instead.
     
  13. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    indeed that works! Thanks for the hint :)

    Now the problem is going to be the following: how can we know about these combinations? ...

    I wrote a wizard that goes over each reflection done ( within PlayMaker ) and output the linker xml content, and so it seems I will have to start creating rules for additional types to preserve... Is there a list somewhere of these types that requires additional preservation entries?

    Bye,

    Jean
     
  14. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    @Jean Fabre

    No, unfortunately we don't have a good way to understand these dependencies in the managed code stripper right now. We have some ideas about how to improve this situation though. We need to extend the stripper to understand a relationship like this: "If A depends on B, and B is preserved, preserve A as well." But we don't have that yet.

    The safest thing to do now is to keep everything in the UnitEngine assembly (or namespace). Of course doing that may have a noticeable impact on the build size though.
     
  15. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Thanks for the infos.

    Indeed keeping the whole UnityEngine would defeat the purpose of the linker and optimized build sizes...

    So, I have implemented a hardcoded list of types to includes if inherited by the class being reflected. It doesn't cover other similar cases, but at least I'll be able to make updates as we find other classes like BoxCollider2D.


    Bye,

    Jean
     
  16. natelwallis

    natelwallis

    Joined:
    Jun 1, 2018
    Posts:
    1
    Hi Jean-Fabre.... Any chance you can share this list? I am currently trying to figure out the most efficient way to generate a link.xml file for AssetBundles I am loading