【发布时间】:2018-08-16 03:21:31
【问题描述】:
在Unity3D C#脚本中,对Component的访问涉及GetComponent()。
x = someGameObject.GetComponent<MyComponent>.field1;
在 Unity3D Javascript 中,允许对 Component 进行鸭式访问,如下所示:
x = someGameObject.field1;
有没有什么方法可以在不调用 C# 脚本中的 GetComponent() 的情况下访问 Component?
【问题讨论】:
-
在javascript中,如果你有多个具有相同字段名称的组件,你如何区分它们?
标签: unity3d duck-typing