【发布时间】:2020-08-02 00:03:11
【问题描述】:
如何从附加到光线交互器的 Unity(XR 交互工具包)脚本中调用函数?我所拥有的正是一个作为 XR 射线交互器制作的游戏对象,并附加了 XR 直接交互器脚本。我想从该脚本调用函数 GetValidTargets 以查看它的目标游戏对象。如何在另一个脚本中调用此函数?我已经指定了 GameObject 并尝试了不同的方法来实现它,例如 GetComponent()。
这是函数在脚本中所说的,所以在我调用它之后会出现。
/// Retrieve the list of interactables that this interactor could possibly interact with this frame.
/// This list is sorted by priority (in this case distance).
/// <param name="validTargets">Populated List of interactables that are valid for selection or hover.</param>
public override void GetValidTargets(List<XRBaseInteractable> validTargets)
如何调用这个函数?
【问题讨论】: