【发布时间】:2022-07-21 00:43:03
【问题描述】:
我收到一条错误消息,告诉我“PlayerLook”不包含“ProcessLook”的定义,并且找不到接受“PlayerLook”类型的第一个参数的可访问扩展方法“ProcessLook”(您是否缺少 using 指令还是程序集参考?)。我已经重新输入了整个脚本,但我仍然收到同样的错误
这是代码,错误可以在 (33,14) 行找到
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class InputManager : MonoBehaviour
{
private PlayerInput playerInput;
private PlayerInput.OnFootActions onFoot;
private PlayerMotor motor;
private PlayerLook look;
// Start is called before the first frame update
void Awake()
{
playerInput = new PlayerInput();
onFoot = playerInput.OnFoot;
motor = GetComponent<PlayerMotor>();
look = GetComponent<PlayerLook>();
onFoot.Jump.performed += ctx => motor.Jump();
}
// Update is called once per frame
void FixedUpdate()
{
// tell the playermotor to move using the value from our movement action
motor.ProcessMove(onFoot.Movement.ReadValue<Vector2>());
}
private void LateUpdate()
{
look.ProcessLook(onFoot.Look.ReadValue<Vector2>());
}
private void OnEnable()
{
onFoot.Enable();
}
private void OnDisable()
{
onFoot.Disable();
}
}
【问题讨论】:
-
ProcessLook() 的形式参数和实际参数之间的某些东西似乎不对劲。你能发布那个方法的定义吗?
-
方法的定义是什么意思(对不起,我是这种东西的新手)
-
点击look.ProcessLook(onFoot.Look.ReadValue
());然后选择转到定义。贴出函数的第一行,而不是整个正文。 -
很抱歉,我仍然对您要说的内容感到困惑。如何找到方法的定义。
-
在 Visual Studio 中,只需右键单击函数“ProcessLook”,然后选择“转到定义”。