Unity版本代码模版:
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
public class UIIosWifi : MonoBehaviour {
//Unity将调用.m里的TestMsg()方法。
[DllImport("__Internal")]
private static extern void TestMsg();//测试信息发送
[DllImport("__Internal")]
private static extern void TestSendString(string s);//测试发送字符串
[DllImport("__Internal")]
private static extern string TestGetString();//测试接收字符串
void Start () {
}
void UnityToIosVoid()
{
TestMsg();
}
void UnityToIosString()
{
TestSendString("Unity将数据发送给IOs String类型");
}
void UnityGetIos()
{
string IosGet = TestGetString();
Debug.Log(IosGet);
分析: