本文介绍了C# 找不到统一自动生成的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好的,所以我正在学习使用新的 InputActions 并且我已经使用
Okay so I'm learning to use the new InputActions and I've created a C# scripts using
这就是我得到的:
// GENERATED AUTOMATICALLY FROM 'Assets/PlayerControls.inputactions'
using System.Collections;
using System.Collections.Generic;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
public class PlayerControls : IInputActionCollection
{
private InputActionAsset asset;
public PlayerControls()
{
///
}
}
但是当我尝试创建一个 PlayerControls 对象时,我收到一个错误提示
But when I try to create an PlayerControls object, I get an error saying
找不到类型或命名空间名称PlayerControls"(您是否缺少 using 指令或程序集引用?)
这是我尝试引用它的类:
This is the class where I try to reference it:
using System;
using UnityEngine;
using System.Collections;
using UnityStandardAssets.CrossPlatformInput;
using UnityStandardAssets.Utility;
using Random = UnityEngine.Random;
using UnityEngine.InputSystem;
namespace UnityStandardAssets.Characters.FirstPerson
{
public class FirstPersonController : MonoBehaviour
{
private PlayerControls controls; // ERROR HERE
}
}
推荐答案
将 PlayerControls
类包裹在命名空间中,然后在您的类中添加一个 using
语句,指向PlayerControls
类所在的命名空间.
Wrap the PlayerControls
class in a namespace, then add a using
statement in your class that points to the namespace where your PlayerControls
class lives.
这篇关于C# 找不到统一自动生成的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!