RuntimeInitializeOnLoadMethod doesn't run on children

Hello,

For some reason, the RuntimeInitializeOnLoadMethod doesn’t seem to work on child classes.

Aka if I have a Monobehavior “Base” that has the “RuntimeInitializeOnLoadMethod” attribute on a static function, this function is not triggered for another Monobehavior class that is based on “Base”.

I’m guessing that when the system scans for the attribute, it accidentally does not check for inherited classes. Naturally this is not the ideal.

As you can’t override static methods, why do you think it’s useful if Unity would call the same method for each derived type?

generics!

public class Singleton<T> {
private T instance;
}

public class MyManager : Singleton<MyManager> { }
11 Likes