【ZenjectException】Instantiator should not be used to create new mono behaviours. というエラー

Zenjectでのエラー。

ZenjectException: Assert hit! Error occurred while instantiating object of type ‘xxxx’. Instantiator should not be used to create new mono behaviours. Must use InstantiatePrefabForComponent, InstantiatePrefab, or InstantiateComponent.

めちゃくちゃ単純なエラーで、エラー文にもしっかりと解決方法が書いてあるのですが。。。

今後Zenject(今はExtenject)を使うことも多そうなので、一応記事にしました。

原因と解決方法

生成するクラスがMonoBehaviourを継承していたため、エラーになっていたのでした。

MonoBehaviourの継承を外すと、エラーが出ず正常に動作しました。

コメント