如何从unity3D c#代码调用c库
我不熟悉unity3D和C#(以及IOS:),但需要在iPhone上使用遗留的C库(.h&.a文件)。我已经从unity文档中阅读了一些关于插件的内容,但仍然被复杂的过程所淹没。有谁能告诉我走出困境的正确方法吗?谢谢 通过这个。这提供了为iOS制作插件的想法。如果有任何疑问,请询问 插件的一个实例 1) 在Unity的plugins文件夹中创建一个名为AppControllerBinding.cs的C#文件,并按如下方式添加代码:如何从unity3D c#代码调用c库,c#,iphone,plugins,unity3d,.a,C#,Iphone,Plugins,Unity3d,.a,我不熟悉unity3D和C#(以及IOS:),但需要在iPhone上使用遗留的C库(.h&.a文件)。我已经从unity文档中阅读了一些关于插件的内容,但仍然被复杂的过程所淹没。有谁能告诉我走出困境的正确方法吗?谢谢 通过这个。这提供了为iOS制作插件的想法。如果有任何疑问,请询问 插件的一个实例 1) 在Unity的plugins文件夹中创建一个名为AppControllerBinding.cs的C#文件,并按如下方式添加代码: using UnityEngine; using
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
// All Objective-C exposed methods should be bound here
public class AppControllerBinding
{
[DllImport("__Internal")]
private static extern void _MyFunction(string myName);
public static void MyFunction(string MyNameIN)
{
// Call plugin only when running on real device
if( Application.platform == RuntimePlatform.IPhonePlayer )
_MyFunction(MyNameIN);
}
}
2) 将MyFunction()函数添加到Xcode内AppController.mm文件的底部,如下所示(在@end语句之后):
经历这一切。这提供了为iOS制作插件的想法。如果有任何疑问,请询问
插件的一个实例
1) 在Unity的plugins文件夹中创建一个名为AppControllerBinding.cs的C#文件,并按如下方式添加代码:
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
// All Objective-C exposed methods should be bound here
public class AppControllerBinding
{
[DllImport("__Internal")]
private static extern void _MyFunction(string myName);
public static void MyFunction(string MyNameIN)
{
// Call plugin only when running on real device
if( Application.platform == RuntimePlatform.IPhonePlayer )
_MyFunction(MyNameIN);
}
}
2) 将MyFunction()函数添加到Xcode内AppController.mm文件的底部,如下所示(在@end语句之后):
AppControllerBinding.cs可以位于资产下的任何位置,IMO不应位于插件下。Plugins/iOS下的所有内容都要复制(或符号链接)到Xcode项目。Xcode不知道如何处理C#文件,因此必须将libray文件和头放在那里。AppControllerBinding.cs可以放在资产下的任何位置,IMO不应该放在插件下。Plugins/iOS下的所有内容都要复制(或符号链接)到Xcode项目。Xcode不知道如何使用C#文件进行dal,所以必须将Libraray文件和头放在那里。以下方法对u有效吗???以下方法对u有效吗。。??
AppControllerBinding.MyFunction("Nick");