Unity:只有鼠标适用于第一个输入(EventSystem / Canvas)

时间:2016-02-23 08:29:21

标签: c# user-interface unity3d

在Unity中,我有一个简单的世界空间画布,只需设置一个按钮。 如果用鼠标单击按钮就可以了。 如果您使用其他方法(如“操纵杆按钮0”),则不会激活该按钮。 使用“操纵杆按钮0”寄存器点击后续按钮后,单击“鼠标按钮0”。

其他信息;如果将项目设置为VR或将光标移离按钮“操纵杆按钮0”,即使光标未在按钮上方,也会继续激活按钮。按下“鼠标按钮0”取消按钮后,它将停止。

目标是使用“操纵杆按钮0”/“操纵杆按钮1”作为画布的唯一输入,并最终使用游戏手柄获得鼠标外观功能。 任何想法发生了什么/如何使这个工作?

输入是默认的统一设置。 ('鼠标0'仅映射到'Fire1'/未映射到'提交')(EventSystem的“提交按钮”映射到“提交”)

见脚本:

using UnityEngine;
using System.Collections;

public class ButtonTestScript : MonoBehaviour {

// Update is called once per frame
void Update () {

    if (Input.GetButtonDown("Submit"))
        Debug.Log("Submit");
    else if(Input.GetButtonDown("Cancel"))
        Debug.Log("Cancel");

    //Lock The Cusor
    Cursor.lockState = CursorLockMode.Locked;
    Cursor.visible = true;

}

public void ButtonClick()
{
    Debug.Log("Button Clicked = " + gameObject.name);
}

}

1 个答案:

答案 0 :(得分:0)

简短的回答是系统不能像这样工作。更长的答案是: https://unity3d.com/learn/tutorials/topics/virtual-reality/interaction-vr