Unity and iOS interaction

Source: Internet
Author: User

Unity and iOS interaction is much simpler, direct export Xcode project, this everyone knows how to operate it, two times development needs iOS code integration into unity, in fact, integration is very simple to find the Iphone_ in the exported Xcode project The Onunityready () method in view.mm, unity is also equivalent to a view in iOS,[getappcontroller()showgameui:_ Maindisplay,window]; Load the game view, this method in Unityappcontroller,-(void) Showgameui: (uiwindow*) window, show view as _rootview, Want to integrate their own view, addsub on it, the specific will be iOS to understand, will not be the first to understand the iOS, the interaction is very simple,

The code for unity and iOS interaction must be written in the class under the exported project class file, where the call is not responding elsewhere, Unity calls iOS

[DllImport ("__internal")]private static extern  void  _hideview (); [ DllImport ("__internal")]private static extern  void  _displayingview (); [ DllImport ("__internal")]private static extern  void _sendjsondata (string stringvalue); [ DllImport ("__internal")]private static extern  void _rotatetrigger (int index);

Unity calls the iOS declaration interface, which passes parameters, and invokes the appropriate method when used. _rotatetrigger(-1); Recommend that you judge the device to call,

iOS side

+ (void) Rotatefurnitureto3d: (const char *) strangle{    unitysendmessage ("Target", "rotatefurniture", strangle);}

This is the iOS call unity using code, write it in the corresponding class, unity has provided the appropriate method,

But Unity calls iOS, because unity is the C # calling code OBJECT-C does not support

extern "C" {    void _sendjsondata (const char* stringvalue)    {        [Ardbmanager   Storeprogramjson: StringValue];}    }

Can realize the interaction, specific people can do a test, do not understand the exchange at any time, a little progress every day


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.