Unity3d and iOS Interactive solutions

Source: Internet
Author: User

Original address: http://bbs.18183.com/thread-456979-1-1.html

This post finally by Ah, will libai on 2014-2-27 11:17 Edit

" to give a person to fish , rather than to teach people to fishing ", Unity3d Call the iOS version of 91SDK as an example , using C #/C/obj-c interaction principle,This article willDetailMediumShaoxingUnity3dwith iOSRoomSolutions for Interaction.  First, open Xcode to create a new empty project, and refer to the 91SDK development documentation to introduce 91SDK and configure the environment. after the configuration is complete, create a obj-c class file named "Lssdkconector". When finished, the current project should be<ignore_js_op>  LsSdkConector.h file We don't have to change it. Keep it as it is. <ignore_js_op> Next we start making the C interface in the LSSDKCONECTOR.M file and calling the 91SDK iOS method. after introducing the necessary header file, I divided the code of the file into 3 regions. the Code a zone is used to define the APIs that the C interface must implement. <ignore_js_op> The Code B area is used to implement the interface for the A zone code, and the iOS method to invoke 91SDK is straightforward, and the Code B area is written as a method to invoke the Code C area. <ignore_js_op> The code C area is used to implement a true 91SDK Obj-c method. <ignore_js_op> In your project:code A area as a direct copy of the Apply;the Code B area can write tool methods and methods to invoke iOS;The code C region to write 91SDK iOS method, you need what API to write, finished writing in the Code B area to add C call method.  in writing code, some people might ask Obj-c if there is a callback in the API, how does unity know that the obj-c callback is over? A : Obj-c calls Unity's API, you can use the "unitysendmessage" method , the specific use of methods to see Uinty help.   so we finished the C interface and the 91SDK API code, next we do the uinity3d aspect of the code processing. we created the Code folder and the plugins folder under the assets of the Unity3d project. <ignore_js_op>copy LsSdkConector.h and lssdkconector.m to the Plugins folder and write our Unity call obj-c method in the Code folder. new C # file "LsSdkConector.cs", in this file, we divide the code into a, b two areas.  code A area to write the C language interface, where the interface method to correspond to "LSSDKCONECTOR.M" in the code region B of the method name. <ignore_js_op> The code in Area B writes the method of Unity3d call Obj-c, where the code note is used to implement method calls between Unity3d, C # Methods within the method of the call. <ignore_js_op> This completes the Unity3d access to the 91sdk-ios version of the solution. <ignore_js_op> Next, let's test if this solution works. To create a new "LisiTest.cs" file in the Code folder, edit the following code:<ignore_js_op>and drag the C # file to the main Camera binding.   unity3d to iOS project must be set Bundleidentifier,: <ignore_js_op>  Click the "Build" button to create an iOS project, open the iOS project, and LsSdkConector.h and LSSDKCONECTOR.M drag into the Classes folder of your iOS project <ignore_js_op>  Follow the Environment configuration section in the 91SDK document, reference the SDK, add the system library, and do the environment configuration. before you pack to your iOS device, check the configuration of your iOS project, note that OBJC is written in column 1th, and be aware of the case. <ignore_js_op><ignore_js_op> choose to pack with iOS device and you'll find Unity3d call iOS successful!!  This article is to tell you the Unity3d and iOS interaction solution, code specification problem is not the focus of this article, such as 91SDK initialization in the SDK documentation is recommended in the Appdelegate file initialization.   Accessories:<ignore_js_op>documents mentioned in the article. zip (2.25 KB, Downloads: 401)



Unity3d and Android interaction can refer to my other article:"real Unity3d access 91SDK Android Version"

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.