- Home /
Why does IL2CPP replace the "new" with Activator.CreateInstance?
private void FooA<T>() where T: new() {
var t = new T();
}
public void FooB<T>() {
FooA<SomeGenericClass<T>>();
}
For some reason IL2CPP can't make AOT code for the SomeGenericClass constructor if we call FooB. Also I saw that the "new T()" was replaced by "Activator.CreateInstance". Is that "generic sharing"? If yes, how can I disable it for my project? But it will be nice to disable for all generic classes in some namespace.
Thanks for help.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612162333im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Generic virtual methods on IL2CPP: how it works? 1 Answer
ExecutionEngineException - Error at iOS Runtime with parse.com SDK 0 Answers
unity3d(5.3.0f4) app crash on IOS 1 Answer
Unity Mono AOT iOS failure for generic method 0 Answers
iOS JIT compile error on Generic method called with basic types (int, bool, float) 1 Answer