unity与iOS原生交互的代码(三)

来源:互联网 发布:新娘梦工厂提取数据 编辑:程序博客网 时间:2024/06/17 05:11

1、Unity调用iOS
1.1 在unityC#中:

[ DllImport( "__Internal" )]private static extern int _showSelectTitleDialog ( string title, string msg);

1.2 在xcode object- c 中

#if defined (__cplusplus)extern "C"{#endif    void _showSelectTitleDialog( char *title,  char *msg) {        NSString *content = [NSString stringWithUTF8String:title];        NSString *message = [NSString stringWithUTF8String:msg];//在这里写自己想要做的处理 }#if defined (__cplusplus)}#endif

2、iOS与Unity的交互
2.1 在xcode object- c 中

UnitySendMessage("Main Camera", "OnClick", "交互");

2.2 在C#中

public void OnClick ( string idStr){      int id = int.Parse (idStr);      //根据自己的实际情况做代码处理     }}

参考地址:
http://docs.unity3d.com/Manual/PluginsForIOS.html
http://www.cnblogs.com/quansir/p/6383116.html

原创粉丝点击