【发布时间】:2019-11-05 22:34:25
【问题描述】:
我有一个物理 Raycaster 连接到相机。指针单击事件触发器工作正常。但是我需要从源代码中做到这一点。这些是我的尝试:
private void SetOnPushButtonFireManager(){
cardboard.OnTrigger += () => {
Debug.Log("Button triggered!");
RaycastHit hit;
// if(Physics.Raycast(headGameObject.GetComponent<GvrHead>().Gaze, out hit, Mathf.Infinity)){
if(Physics.Raycast(cameraGameObject.transform.position, cameraGameObject.transform.forward, out hit, Mathf.Infinity)){
Debug.Log("Collision detected!");
}
};
}
“按钮触发了!”显示在控制台中。不幸的是“检测到碰撞!”不是。但是,指针单击事件触发器工作正常(检查器中附加的组件)。我怎么知道发生了什么?为什么它不起作用?
更新:我在这里回答了这个答案:http://answers.unity3d.com/answers/1200449/view.html
(stackoverflow 不允许我删除这个问题)
【问题讨论】:
标签: unity3d unity5 google-cardboard raycasting google-vr