c# - 在下面的代码中解释 GvrPointerInputModule.pointer
问题描述
我在我的脚本中添加了以下代码行,以启用对在 google daydream 中播放的统一 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
}
}
有人可以解释一下为什么我需要在游戏过程中启用控制器主和控制器,它们在层次结构中没有被禁用。并解释第3行代码
解决方案
controllerMain
和controllerPointer
变量分别只是对GvrControllerMain和GvrControllerPointer GameObject预制件的引用。GvrControllerPointer 提供用于光线投射的内置激光指示器。需要 GvrControllerMain 才能使用 Daydream 控制器。
呼叫controllerMain.SetActive(true)
将激活GvrControllerMain
。当你调用SetActive
它时,同样的事情也适用于 GvrControllerPointer。运行 Daydream 时,这两个都应该被激活。这就是为什么在运行时激活和停用它们的原因,因为那时您可以确定这是否是白日梦设备。
GvrPointerInputModule.Pointer
用于设置指针类型。有一个GvrLaserPointer
和GvrReticlePointer
。在您的示例中,您告诉 Gvr 模块使用GvrLaserPointer
并且是一种激光视觉,当光标不在他们的视野中时,它可以帮助用户定位光标。
推荐阅读
- mysql - 合并两个不共享相同主键的表
- sql - 在 SQL Server 代理中运行 SSIS 包过长
- flutter - 下拉框不显示所选值
- php - 将 PHP 数组拆分为两个单独的数组
- ios - 如何从firestore快速从集合中获取文档ID
- css - z-index 在非内联时被浏览器忽略(当内联和非内联具有完全相同的样式时再次被忽略)
- apache-kafka - 如何使用 Java 代码使用 Kafka 连接器?
- c++ - C++ 双重释放或损坏(出)
- docker - Shopware 6 泊坞窗 | 未显示更改
- python - 使用 PyAny 在 Python 中的 TypeError 在反射数字模拟器(例如 __radd__)中用于 Rust pyo3 pyclass 结构