先说严重性
造成LogStringToConsole高调用(不排除有一部分是代码打印的)
You are trying to create a MonoBehaviour using the 'new' keyword.
This is not allowed. MonoBehaviours can only be added using AddComponent().
该错误出自unity的Editor.log日志中
macOS ~/Library/Logs/Unity/Editor.log
Windows C:\Users\username\AppData\Local\Unity\Editor\Editor.log
word is poor show me the code,问题原因就是在B类中通过New 的方式使用A component
虽然console不会报错,但会给性能带来比较大的影响,component毕竟是毕竟耗性能的
public class A : MonoBehaviour {
...
}
private A a = new A();
public class B: MonoBehaviour {
...
}