c#使用vr box 手柄开发

来源:互联网 发布:阿里云怎么打开端口 编辑:程序博客网 时间:2024/05/17 08:44
   string currentButton = ""; void Update ()  {        var values = Enum.GetValues(typeof(KeyCode));//存储所有的按键          for (int x = 0; x < values.Length; x++)        {            if (Input.GetKeyDown((KeyCode)values.GetValue(x)))            {                currentButton = values.GetValue(x).ToString();//遍历并获取当前按下的按键              }        }  }   void OnGUI()    {        GUIStyle fontStyle = new GUIStyle();        fontStyle.normal.background = null;    //设置背景填充          fontStyle.normal.textColor = new Color(1, 0, 0);   //设置字体颜色          fontStyle.fontSize = 40;        GUI.TextArea(new Rect(0, 0, 250, 40), "Current Button : " + currentButton, fontStyle);//使用GUI在屏幕上面实时打印当前按下的按键          GUI.TextArea(new Rect(0, 40, 250, 40), "Horizontal : " + Input.GetAxis("Horizontal") + "  Vertical : " + Input.GetAxis("Vertical"), fontStyle);//使用GUI在屏幕上面实时打印当前按下的按键      }
原创粉丝点击