How to make a iOS plugin for Unity3d
- by DannoEterno
I've passed last 2 days reading articles and book for understand how can i make a plugin for iOS in Unity. Basically i need just a demo for understand how it work. For now i've tried to make this process (with really poor luck):
I've started a new project in Unity and writed a simple script
using UnityEngine;
using System.Collections;
using System;
using System.Runtime.InteropServices;
public class CallPlugin : MonoBehaviour {
[DllImport ("__Internal")]
private static extern int test();
void Start ()
{
Debug.Log(test());
}
}
Then i've created a project in Xcode with this simple script:
extern "C"{
int test()
{
int che = 5;
return che;
}
}
Then i've tried:
to put the .mm and .h in the Assets/Plugins/iOS = nothing
to build the unity project and than add the .h and .mm in the Xcode project = nothing
In Unity i will always get the EntryPointNotFoundException, so unity see the file but is unable to reach the method. The problem is... how?! :)
Maybe i miss something or i've done something wrong?
Thanks a lot for every help that you can give me :)