disallow_multiple¶
函数位于 InfEngine.components
描述¶
Prevent multiple instances of this component on a GameObject.
Usable with or without parentheses::
@disallow_multiple
class MySingleton(InfComponent): ...
@disallow_multiple()
class MySingleton(InfComponent): ...
description
防止在同一 GameObject 上附加多个同类型组件实例。引擎会拒绝添加重复组件并输出警告。
等价于 Unity 的 [DisallowMultipleComponent] 特性。可以带或不带括号使用。
示例¶
example