ERIC星辰 2020-07-26 16:58 采纳率: 0%
浏览 961

unity Event.current为空的问题

如题,Event.current获取出来为NULL,然而获取当前输入的keyCode我需要获取到Evert.current。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    private Animator animator;//玩家的动画
    // Start is called before the first frame update
    void Start()
    {
        animator = GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update()
    {
        Move();
    }

    void Move()
    {
        if (!animator.GetBool("OnMoving") && Input.anyKey)
        {
            Debug.Log(Event.current);
            if (Input.anyKeyDown)
            {
                Event e = Event.current;
                if (e.isKey)
                {
                    Debug.Log("Current Key is : " + Event.current.keyCode.ToString());
                }
            }
        }
    }
}

图片说明

  • 写回答

3条回答 默认 最新

  • zqbnqsdsmd 2020-07-31 08:37
    关注
    评论

报告相同问题?

悬赏问题

  • ¥20 公众号如何实现点击超链接后自动发送文字
  • ¥15 用php隐藏类名和增加类名
  • ¥15 算法设计与分析课程的提问
  • ¥20 汇川小型plc控制小米微电机
  • ¥15 用MATLAB汇总拟合图
  • ¥15 智能除草机器人方案设计
  • ¥15 对接wps协作接口实现消息发送
  • ¥15 SQLite 出现“Database is locked” 如何解决?
  • ¥15 已经加了学校的隶属邮箱了,为什么还是进不去github education?😭
  • ¥15 求会做聚类,TCN的朋友有偿线上指导。以下是目前遇到的问题