• 【Unity3D日常BUG】Unity3D解决“找不到类型或命名空间名称“XXX”(您是否缺少using指令或程序集引用?)”等问题


    推荐阅读

    大家好,我是佛系工程师☆恬静的小魔龙☆,不定时更新Unity开发技巧,觉得有用记得一键三连哦。

    一、前言

    首先,看一下跟我是不是类似的问题:
    在这里插入图片描述
    缺少命名空间引用的问题。

    类似的问题有:

    The type or namespace name `MySql’ could not be found. Are you missing an assembly referen

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

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

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

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

    UP是从Visual Studio的NuGet包管理器直接安装的插件集,在Visual Studio是没有报错的,但是在Unity中会报错。

    二、原因分析

    这个主要原因以下几个方便:

    1、Unity的版本问题,老版本无法支持新的依赖库。
    2、Unity的目标框架库不支持.Net的框架库
    3、Unity中没有加入这个dll

    三、解决问题

    知道问题了就好解决了。

    3-1、Unity版本问题

    如果是Unity 的版本问题就升级版本

    3-2、Unity不支持目标框架库

    如果是Unity的目标框架库不支持.Net的框架库。

    在Unity编辑器中,点击File→Build Settings→Player找到Api Compatibility Level:
    在这里插入图片描述
    将.NET Standard 2.0改成.NET 4.x。

    安装.NET 4.6框架的,可以改成4.6。

    3-3、Unity没有导入dll

    有童鞋会说了:我Unity目标框架库、Unity的版本都没有问题,但是还有报错怎么办呢。

    那就要根据这个缺少的程序集去找到对应的dll文件,然后放到Unity的Plugins文件夹中:

    比如说我缺少JWT和Newtonsoft的程序集,我就找到了对应的dll文件:

    在这里插入图片描述
    放到Unity的Plugins文件夹中:
    在这里插入图片描述
    等到编译完,报错就消失了。

    至于dll文件去哪里找。。。说实话我也没有太好的办法,百度。。或者去github找,有更好的方法的同学也可以留言告诉我。

  • 相关阅读:
    【面试经典150 | 数组】移除元素
    Python的高频写法
    世界杯观后感
    KMP算法,next表的创建。
    69.Qt 实现Https ssl证书与内网服务器ip进行双向认证
    java-net-php-python-jsp刺绣作品展示网站计算机毕业设计程序
    python之APScheduler
    Studio One6.5最新版本新增了对Linux的支持
    三角网格库Triangle的使用
    维格云数据回收站入门教程
  • 原文地址:https://blog.csdn.net/q764424567/article/details/125798478