本文介绍了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
这是我尝试引用它的类:
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#找不到统一的自动生成的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!