Unity "xxx Class" is missing the class attribute 'ExtensionOfNativeClass' 解决方案

Unity "xxx Class" is missing the class attribute 'ExtensionOfNativeClass'
翻译:‘xxx Class’缺少类属性 `ExtensionOfNativeClass`

这个就是当脚本继承了MonoBehaiour, 才会有这个属性;然而没有继承自MonoBehaviour, 却被挂到了场景中(这样的神操作不知道是怎么发生的)。

解决办法:
1) 让该类继承自`MonoBehaviour`即可,但要注意Unity对采用直接调用构造函数,如 new ClassA() 形式创建MonoBehaviour脚本对象的方式会报Warnning的;
2) 把脚本在场景中挂载中移除即可,就像删除MonoBehaviour对象一样

 

参考以及感谢网友们的无私贡献:
https://blog.csdn.net/Tang_AHMET/article/details/108163565

posted @ 2023-03-04 14:03  opencoder  阅读(980)  评论(0编辑  收藏  举报