U3d to interact with iOS

Source: Internet
Author: User

Original address: http://502317120.blog.51cto.com/4062300/1077733

There are many situations in development where you use U3D to invoke functions in iOS. For example, in u3d, we need to call a function called iOS, for example: the ad plugin. (both have ready-made code that everyone just needs to call the next one.) This time we need to write a method in U3d. This method calls the function in iOS.  U3d is written as follows: C # version: [DllImport ("__internal")]private static extern void _useios (); void U3duseios () {if (Application.platform = = Runtimeplatform.iphoneplayer)//If the current platform is iOS
{_useios ();//Call _useios Method}} This code needs to import the using System.Runtime.InteropServices; This header file.  The _useios () method name in this code is the name of the method we want to implement in iOS. U3duseios () This method is the name of the method that you want to invoke in U3d. Here's how it's written in iOS: extern "C"
{void _useios () {///Add the code you want to invoke}} This code is the _useios () method declared in iOS that implements U3d. This piece of code can be added anywhere. But I added it to the appcontroller.mm. More lazy. All right, I'm going to write about it here today. Please leave a message.

This article is from the "Zhang Pengfei" blog, make sure to keep this source http://502317120.blog.51cto.com/4062300/1077733

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.