C#找不到统一的自动生成的类 [英] C# cant find a unity auto generated class

查看:46
本文介绍了C#找不到统一的自动生成的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我正在学习使用新的InputActions,并且已经使用

Okay so I'm learning to use the new InputActions and I've created a C# scripts using

https://prnt.sc/oyaj5l

这就是我得到的:

// 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指令或程序集引用?)

The type or namespace name 'PlayerControls' could not be found (are you missing a using directive or an assembly reference?)

这是我尝试引用它的类:

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆