- Home /
Generic virtual methods on IL2CPP: how it works?
Documentation Scripting restrictions contains restrictions of generic virtual methods on IL2CPP in section "Generic virtual methods". However, the code example given in this section, that should not work on IL2CPP, works fine on Unity 2019.3.0f6 Windows IL2CPP build. I also discovered that our dev team use the generic virtual methods in production without any problems.
Please, describe the actual restrictions of the generic virtual methods.
Did you try their example exactly as it is without any changes?
Answer by JoshPeterson · Mar 02, 2020 at 01:23 PM
The restrictions for generic virtual methods occur when the generic arguments are value types (e.g int
,double
, etc.). Any generic virtual methods with reference type generic arguments will work fine.
I tested the exact code sample in the documentation with reference types, primitive value types and user defined value types on Standalone(IL2CPP) and WebGL platform, they all worked. It seems that the restriction no longer exists as long as the method is not called via reflection and all possible implementation of the method will be generated in the output cpp files.