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