Unity You are trying to create

2022-05-12  本文已影响0人  114105lijia

在Unity中,继承于MonoBehavior的对象,要避免使用new关键字来创建,而必须使用AddComponent或Instantiate函数来创建

之所以出现这个警告,是因为我们使用new方式来创建对象:

PlayVideoTool playVideoTool = new PlayVideoTool();

需要改成下面这样:

playVideoTool = transform.gameObject.AddComponent<PlayVideoTool>();
上一篇下一篇

猜你喜欢

热点阅读