在类级别声明 var 组件或稍后在代码中使用 GetComponent 引用它们会更好吗?
例子:
vitals = GetComponent<Vitals>();
weapon = GetComponent<Weapon>();
还是我应该使用
GetComponent<Vitals>.ApplyHealth(25);
哪个更适合性能/内存使用?
在类级别声明 var 组件或稍后在代码中使用 GetComponent 引用它们会更好吗?
例子:
vitals = GetComponent<Vitals>();
weapon = GetComponent<Weapon>();
还是我应该使用
GetComponent<Vitals>.ApplyHealth(25);
哪个更适合性能/内存使用?