Mutual invocation between unity and iOS native code

Source: Internet
Author: User

Effect:

Code: "GitHub" Unity_ios_plugin_demo
Key: 1, Unity calls ios:1.1, in Unity C #:
[DllImport ("__internal")]private static extern int _showselecttitledialog (string title, String msg);

1.2. In Xcode objective-c:

extern "C" {    int _showselecttitledialog (const char *title, const char *msg) {        return [[Undialogmanager Sharedmana GER]                showselectdialog:[nsstring Stringwithutf8string:title]                message:[nsstring stringwithutf8string:msg] ;    }}

2. Call unity:2.1 in iOS, in Xcode objective-c:
Unitysendmessage ("Dialogmanager", "OnCancel", tag. utf8string);
2.2. In Unity C #:
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);}       }

Reference: http://docs.unity3d.com/Manual/PluginsForIOS.htmlhttps://github.com/asus4/UnityNativeDialogPluginhttp:// blog.csdn.net/wwmusic/article/details/21008289


Document Information

    • Original URL: http://blog.csdn.net/cdztop/article/details/39805803
    • Last modified: October 05, 2014 20:58

Mutual invocation between unity and iOS native code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.