【问题标题】:C# error: 1061 'PlayerLook' does not contain a definition for 'ProcessLook' and no accessible extension method 'ProcessLook'C# 错误:1061“PlayerLook”不包含“ProcessLook”的定义并且没有可访问的扩展方法“ProcessLook”
【发布时间】: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”,然后选择“转到定义”。

标签: c# unity3d


【解决方案1】:

在“输入操作”选项卡中勾选“自动保存”。发生这种情况是因为当我们添加 Look 操作时,它不会立即更新/保存在 C# 文件中。因此,PlayerInput 无法将“Look”识别为方法

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-01-12
    • 2020-06-14
    • 2023-01-19
    • 2020-10-06
    • 2019-05-05
    • 1970-01-01
    • 2023-03-13
    • 2020-01-22
    相关资源
    最近更新 更多