Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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 :)

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Ok, after reading a lot i've found the solution:

Seems that the extern call don't work inside the editor or simulator, so the correct way of doing this is develop for device (after putting the header and the implementation files under Assets/Plugins/iOS).

I hope that this will help some one :)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.