Unity: Null while making new class instance

后端 未结 2 1269
Happy的楠姐
Happy的楠姐 2020-11-22 10:32

I got stuck in pretty dumb situation: I\'m making new instance of the generic class but it returns \"weird\" null.

    Rule rule2 = new Rule(); // initiate t         


        
2条回答
  •  余生分开走
    2020-11-22 11:12

    Just a a follow up, how I ended up doing it and why:

    1. I no longer inherit the Rule class from MonoBehaviour to avoid tracking cretion and deletion of the gameObjects, which appeared to be the pain.

    2. As Invoke method does not exist in generic classes, I replaced it with reflection, as described here

提交回复
热议问题