I didn’t find anything that really clearly laid it out for me; I just struggled through the example project that’s up on the Unity site.
When it’s all said and done (and in retrospect), the example project does show you what to do, but it took me quite awhile to figure out how all the pieces worked together. For whatever reason, I was just being dim that day, I think.
The basics are:
From your Unity app, you need to call a C function:
...
using System.Runtime.InteropServices;
public class MainMenuBinding : MonoBehaviour
{
[DllImport("__Internal")]
private static extern void _levelStartMenu();
public static void levelStartMenu()
{
if( Application.platform != RuntimePlatform.OSXEditor )
_levelStartMenu();
}
So from Unity, I call MainMenuBinding.levelStartMenu(), This then would talk to the function _levelStartMenu in your xCode project that has something like this in it:
extern "C" {
void _levelStartMenu()
{
[[MainMenuBinding sharedManager] ShowLevelStartMenu]; // and this gets you into your Obj-c world...
}
}
(I’ve named both classes that communicates from one environment to another “MainMenuBinding”. I (don’t think) that there’s any reason you need to have them both named the same thing.)
From there, you can then either overlay your own windows, view controllers, etc. on top of the running Unity code (pausing or not pausing Unity by defining “void UnityPause( bool pause );” in your class and using that.
To send a message to Unity from Obj-c, then you use:
void UnitySendMessage( const char * className, const char * methodName, const char * param );
...
...
UnitySendMessage( "UnityCSharpClassName" , "UnityMethod", "WhateverValueToSendToUnity");
I hope that shows all the right steps… at this point I have a somewhat template-d system in place so it’s easy for me to go back and forth between the two, but I may have forgotten a step or two that I did initially in there, though.