如何将MySql Connector导入Unity Project? [英] How do I import MySql Connector into Unity Project?

查看:313
本文介绍了如何将MySql Connector导入Unity Project?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 我尝试将基本dll放入unity的资产文件夹中-结果:等等会导致Unity崩溃错误."
  • 我尝试过手动添加引用-结果:每当编辑器刷新时,Unity都会刷新其引用,因此毫无价值.
  • 我尝试使用NuGet进行安装-结果:由于它可以处理所有依赖关系而未成功,但我却得到:Assets/Scripts/Developing/TalkToDB.cs(3,7):错误CS0246:类型或名称空间找不到名称"MySql".您是否缺少装配参考?

这是使用NuGet然后将dll复制到资产中"的某种组合吗?或类似多余的东西?因为那是关于我的最佳猜测.

Is it some kind of a combination of "Use NuGet then copy the dll into the Assets?" or something redundant like that? cause that's about the best guess I've got.

此外,我尝试了NuGet软件包的几个较旧版本,但均无济于事. 同样,MySql.Data 列在"Assembly-CSharp"的引用下 而且我使用Unity最新的2018.2.5f1(64bit)将Unity设置为4.X框架 (我真的希望我不必为此放弃4.x……我会错过初始化属性值的过程.)

Also, I've tried a couple older versions of the NuGet package to no avail. As well, MySql.Data is listed under the References of "Assembly-CSharp" And my Unity is set to 4.X framework Using Unity's latest 2018.2.5f1 (64bit) (I really hope that I don't have to ditch 4.x for this to work... I'll miss initializing values to properties..)

推荐答案

幸运的是,我遇到了这个问题:

Fortunately I came across this:

如何使MySql Connector/Net与Unity 2017一起使用

关于安全问题.我的关键是,我的所有会话都不得从.NET持久保存-将会有 个高级PHP脚本,用于更改数据以及任何有关提升权限的内容.

And Regarding Security concerns. My Key is none of my sessions should ever be persistent from .NET - There will be advanced PHP scripts for altering of data and anything regarding elevated permissions.

参考:除此之外,

规则例外.

某些数据库供应商可能已经提供了驱动程序以连接到远程数据库,但到目前为止我还没有发现任何驱动程序.

"Some database vendors may have provided drivers to connect to remote databases, but as yet I’m not aware of any.

其他例外包括ODBC连接.例如,我听说开发人员在用Java开发应用程序时能够(或至少试图)使用JDBC连接到MySQL数据库.实际上,这与直接使用二进制驱动程序进行连接并不完全相同,但是,它非常接近..." - 2

Other exceptions include ODBC connectivity. For example, I’ve heard of developers being able to (or at least trying to) connect to MySQL databases using JDBC when developing applications in Java. This is not actually quite the same as connecting directly using a binary driver, however, it comes close..." - 2

这正是我要做的,使用 MySql Connector 与MySql驱动程序交谈(此刻我太累了,无法重命名 (也许它是基于ODBC的?我不记得了.因此是Google.哈哈))

This is exactly what I will be doing, using the MySql Connector to talk to MySql drivers (which I'm too tired at the moment to recall the name of(maybe it's based on ODBC? I can't remember. Thus Google. Lol))

因此,总而言之,使用顶部提供的链接,Unity 2018可以与最新版本兼容(截至本文) MySql连接器.

So all in all, using the link provided at the top, Unity 2018 can be compatible with the latest (as of this post) MySql Connector(s).

但是错误消息:加载脚本程序集'Assets/Plugins/MySql/System.Data.dll'失败!" 到目前为止,它显然无法从app.config中引用connectionString,就像Unity外部的普通C#一样. 话虽这么说,我正在寻找Unity的app.config实现或同等的替代方案.

However the error message: "Loading script assembly 'Assets/Plugins/MySql/System.Data.dll' failed!" And as of yet, it is apparently not able to reference connectionString from an app.config like your normal C# outside of Unity would be able to. This being said, I'm working on finding either Unity's implementation of the app.config, or an equivalent alternative.

除了Unity中的一些烦人的dll加载错误,这些错误不会影响任何东西-除了使我烦恼,并浪费了几个字节的RAM一秒钟(大声笑,y'kno); 一切正常,我记得我不关心将应用程序直接连接到数据库的原因是因为用户拥有的唯一权限是执行权限,因此所有过程都将存储在服务器上(通过存储过程),从而保护了用户的安全.即使咳嗽咳嗽咳嗽时,数据库也不会受到任何潜在的攻击,用户决定对它进行反编译"(甚至是一个单词……吗?)应用.

Aside from a couple annoying dll loading errors in Unity that don't influence anything - other than annoying me and wasting a couple bytes of RAM for a second (lol, y'kno.); All works well and I remember the reason I am not concerned about connecting my application directly to my Database is because the ONLY permissions the users will have is the Execute permission so all procedures will be stored on the server (via Stored Procedures) and thus protecting the database against any potential attacks even if cough coughwhencough ahem, a user decides to "de-compile" (is that even a word...? heh) my application.

我在此处发布了

我花了一个星期才终于弄清楚...

It took me a week to finally figure it out...

您需要使用:

I18N.dll
I18N.West.dll
I18N.*.dll (Optional, they are region specific)
System.Data.dll

来自C:\ Program Files \ Unity \ Editor \ Data \ Mono \ lib \ mono \ 2.0

from C:\Program Files\Unity\Editor\Data\Mono\lib\mono\2.0

不是BleedingEdge路径.然后它将可以正常工作[在Builds中...] 在最新的Unity 2018.2.14f1中得到确认 放入Assets文件夹-此外,项目也需要设置为.Net 4.0

NOT the BleedingEdge path. Then it will work without errors [And in Builds]... confirmed in the latest Unity 2018.2.14f1 Place into the Assets folder - Also the project needs to be set to .Net 4.0

这篇关于如何将MySql Connector导入Unity Project?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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