简体   繁体   English

Unity中的条带集成

[英]Stripe integration in Unity

I am using Unity 2017.2.1f1 running Experimental .NET 4.6 equivalent scripting runtime version with .NET 4.6 compatibility level. 我正在使用运行带有.NET 4.6兼容级别的实验性.NET 4.6等效脚本运行时版本的Unity 2017.2.1f1。

However when i install te latest version of Stripe.net (which requires .NET 4.0) using nuget packet manager i get the error Error CS0246 The type or namespace name 'Stripe' could not be found (are you missing a using directive or an assembly reference?) when trying to use the stripe namespace. 但是,当我使用nuget数据包管理器安装Stripe.net的最新版本(需要.NET 4.0)时,出现Error CS0246 The type or namespace name 'Stripe' could not be found (are you missing a using directive or an assembly reference?)时尝试使用带区名称空间。

I am fairly sure this is being caused by Monodevelop somehow interfering as i am able to use the Stripe namespace when I create a clean .net project and get the very same package with nuget. 我相当确定这是由Monodevelop造成的,因为当我创建一个干净的.net项目并使用nuget获得完全相同的包时,我能够使用Stripe名称空间。

Is there a different way to install the Stripe.net library that would allow me to use the namespace? 有没有其他方法可以安装Stripe.net库,从而允许我使用名称空间?

using Stripe; // not found (in a Unity project)
public class StripeAuthenticate 
{
   void InitStripe()
   {
       StripeConfiguration.SetApiKey("stripe_key");
   }
}

I tried removing the Monobehaviour inheritence but that did not do anything either. 我尝试删除Monobehaviour继承,但这也没有做任何事情。

I have tried following the steps here but since i was already using nuget from the start that didn't do anything for me. 我尝试按照这里的步骤进行操作但是由于我从一开始就已经在使用nuget,因此对我没有任何帮助。

edit: I am aware of UniStripe but this hasn't been updated in years, coupled with the negative reviews I do not feel comfortable using this 编辑:我知道UniStripe,但多年未更新,加上负面评论,我对此感到不舒服

Apparantly the issue lies with Nuget rather than with Monobehaviour. 显然,问题在于Nuget,而不是Monobehaviour。

As Unity pulls all its resources starting from the /Assets/ folder it does not find any libraries installed through the nuget package manager which defaults its download location to what seems to be $(Solutiondir)/packages/<packageName> which is above unity's asset folder. 当Unity从/ Assets /文件夹开始拉动其所有资源时,它找不到通过nuget软件包管理器安装的任何库,该库将其下载位置默认设置为似乎是$(Solutiondir)/packages/<packageName> ,它高于unity的资产夹。

I got around this issue using the following steps: 我通过以下步骤解决了这个问题:

  • Install Stripe using nuget 使用nuget安装Stripe
  • Navigate to SolutionDir/packages 导航到SolutionDir /程序包
  • Copy Stripe and newtonsoft /lib/ folder to a temporary location Stripe和newtonsoft / lib /文件夹复制到一个临时位置
  • Uninstal the packages using nuget UNINSTAL使用的NuGet包
  • Move the /lib/ folder into a directory inside /assets/ 将/ lib /文件夹移至/ assets /中的目录

without uninstalling the packages using nuget first i was getting a ton of error messages saying stripe was already defined. 没有先使用nuget卸载软件包,我收到了很多错误消息,说已经定义了stripe。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM