Search Unity

How do I tell IL2CPP to generate code for a generic method?

Discussion in 'Scripting' started by dadude123, Nov 4, 2019.

  1. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    I have a generic method like
    void MyMethod<T>() { ... }
    and when compiling with IL2CPP the method is missing for some value types I'm using.

    The method is private and defined in another separate library.

    A link.xml file won't help here, as the problem comes from the method being generic.
    IL2CPP can't generate an implementation because T is not known yet.

    I vaguely remember there being a way to instruct IL2CPP to generate generic implementations/instantiations of methods/code by using some attribute.

    [assembly: IL2CPPGenericMethod("SomeLibrary.MyMethod", typeof(SomeStructType))]


    Being able to somehow specify types and generic parameters for it would solve this.
    How can I do this?