在下面的代码中解释GvrPointerInputModule.pointer
Explain GvrPointerInputModule.pointer in the foloowing code
我正在我的脚本中添加以下代码行,以使控制器支持正在 google daydream 中玩的 Unity VR 游戏。如果没有此代码,控制器将不会显示在游戏的最终版本中
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class InputManager : MonoBehaviour
{
public GameObject controllerMain;
public GameObject controllerPointer;
private void Start()
{
controllerMain.SetActive(true);
controllerPointer.SetActive(true);
GvrPointerInputModule.Pointer =
controllerPointer.GetComponentInChildren<GvrLaserPointer>();//3
}
}
有人能解释一下为什么我需要在游戏过程中启用 controllermain 和 controller,它们在层次结构中没有被禁用。
并解释第3行代码
controllerMain
和 controllerPointer
变量分别只是对 GvrControllerMain and GvrControllerPointer GameObject 预制件的引用。 GvrControllerPointer 提供用于光线投射的内置激光指示器。需要 GvrControllerMain 才能使用 Daydream 控制器。
调用 controllerMain.SetActive(true)
将激活 GvrControllerMain
。当您调用 call SetActive
时,同样的事情适用于 GvrControllerPointer。 运行ning daydream 时,这两个都应该被激活。这就是为什么在 运行 时间内激活和取消激活它们的原因,因为那时您可以确定这是否是白日梦设备。
GvrPointerInputModule.Pointer
用于设置指针类型。有一个GvrLaserPointer
和GvrReticlePointer
。在您的示例中,您告诉 Gvr 模块使用 GvrLaserPointer
并且是一种激光视觉,可帮助用户在光标不直接位于他们的视野中时定位他们的光标。
我正在我的脚本中添加以下代码行,以使控制器支持正在 google daydream 中玩的 Unity VR 游戏。如果没有此代码,控制器将不会显示在游戏的最终版本中
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class InputManager : MonoBehaviour
{
public GameObject controllerMain;
public GameObject controllerPointer;
private void Start()
{
controllerMain.SetActive(true);
controllerPointer.SetActive(true);
GvrPointerInputModule.Pointer =
controllerPointer.GetComponentInChildren<GvrLaserPointer>();//3
}
}
有人能解释一下为什么我需要在游戏过程中启用 controllermain 和 controller,它们在层次结构中没有被禁用。 并解释第3行代码
controllerMain
和 controllerPointer
变量分别只是对 GvrControllerMain and GvrControllerPointer GameObject 预制件的引用。 GvrControllerPointer 提供用于光线投射的内置激光指示器。需要 GvrControllerMain 才能使用 Daydream 控制器。
调用 controllerMain.SetActive(true)
将激活 GvrControllerMain
。当您调用 call SetActive
时,同样的事情适用于 GvrControllerPointer。 运行ning daydream 时,这两个都应该被激活。这就是为什么在 运行 时间内激活和取消激活它们的原因,因为那时您可以确定这是否是白日梦设备。
GvrPointerInputModule.Pointer
用于设置指针类型。有一个GvrLaserPointer
和GvrReticlePointer
。在您的示例中,您告诉 Gvr 模块使用 GvrLaserPointer
并且是一种激光视觉,可帮助用户在光标不直接位于他们的视野中时定位他们的光标。