Virtual method overrides not used on AOT

이승우 3 years ago updated by Lazlo Bonin (Lead Developer) 3 years ago 5

1. The B class inherits the A class.

2. I attached BClass to GameObject.

3. Call Virtual Method

Unity Editor Result

Android Result

Check Please

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):

Is this a serious problem?

Pending Review

Can't verify at the moment because I'm quite sick, but I'll have a look ASAP when I get better.

Of course, this is a bug and needs to be fixed. Bolt should support inheritance 100%, on every platform.

Working on Fix

Found the issue. It seems that it is a Unity bug in the way they delegates are converted in IL2CPP.

Basically, using CreateDelegate(type) where type is a base type will not create a proper function pointer in the lookup table to the child method when the delegate is called with a child class; it will keep the pointer to the parent method. (Probably an error in the internals described here).

I can fix it by removing the optimizations for virtual method, but it means they'll be as slow as regular reflection.