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

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
    关注
    评论

报告相同问题?