Obj to CSharp Unity Plugin Question

Hi all,

I’ve written some code that modifies Unity functionality to AppController in Objective C.

For the purposes of discussion this function looks something like this:

  • (void) disableXYZ
    {
    // do stuff here with the AppController object
    }

This code lies inside the @implementation AppController block.

In AppController.h, I have also added this function declaration:

  • (void) disableXYZ;

My question is how do I expose the “disableXYZ” function to Unity through a CSharp plugin.

Obviously, “extern” can’t be used to expose member variables in an Objective C implementation.

Thanks,
Matt

You need to write a function that allows you to modify it from within unity.

variables can not be exposed.

Calling native functions can only be done with Unity iPhone Advanced. As far as I know you can only call C-style functions.

There’s documentation, and an example, in the Unity iPhone documentation (not available on the web) under Unity Manual->Advanced->Plugins.

(/Documentation/Manual/Plugins.html)

Ok. I came up with a way to make this work. It may not be the most elegant solution, but it works.

Basically if you change the - on the from of the method to a +, then the method becomes class level and you can call it like a static method off the class.

Then you just write the C method and extern it.

Thanks,
Matt