Issue with Inheritance when using nested Generic classes in C#

前端 未结 2 633
旧巷少年郎
旧巷少年郎 2020-12-22 06:11

I\'m trying to create a class hierarchy such that I can have:

SpecificScreenController < ScreenController < Singleton

So far I have these set up as:

2条回答
  •  情话喂你
    2020-12-22 06:11

    The problem here is one of covariance. You're assuming that if SpecificScreenController inherits from MonoBehaviour then ScreenController also inherits from ScreenController. It doesn't. You can't do this cast.

提交回复
热议问题