Unity与iOS原生代码之间的相互调用
效果:
代码:
关键:
[ DllImport( "__Internal" )] private static extern int _showSelectTitleDialog ( string title, string msg);
1.2、在Xcode Objective-C中:
extern "C" { int _showSelectTitleDialog(const char *title, const char *msg) { return [[UNDialogManager sharedManager] showSelectDialog:[NSString stringWithUTF8String:title] message:[NSString stringWithUTF8String:msg]]; } }
UnitySendMessage("DialogManager", "OnCancel", tag.UTF8String);
public void OnCancel ( string idStr) { int id = int.Parse (idStr); if (_delegates.ContainsKey (id)) { _delegates [id] (-1); _delegates.Remove (id); Debug.LogWarning ( "===OnCancel idStr1:" + idStr); } else { Debug.LogWarning ( "===OnCancel idStr2:" + idStr); } }
参考资料:
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。