0

I have a certain task where i want to pass a UIView to one of the SDK's in my iOS project. Now, my project is a simple 2D game build in Unity 3d. I want to send the Panel in my Canvas to that SDK as UIView.

I am aware of iOS and Unity communication. It happens using as Char*.

I am not sure how should i access that GameObject Panel in my iOS code as UIView. I will be very thankful if i receive any help on this.

1 Answers1

0

Above is one of solution that you can access from ios interface but before see this, read https://docs.unity3d.com/Manual/PluginsForIOS.html. it will help to understand how unity and native code can communicate.

iOS: test.mm

#import "Unity/UnityInterface.h"

...
...

-(void)SendMessage
{
    UnitySendMessage("MessageGameCommunicator", "Receiver", [message UTF8String]);
}

Unity: Commnicator.cs, MessageGameCommunicator (GameObject name)

    public class Commnicator : MonoBehaviour
    {
        public static void Receiver(string message)
        {
            // ...
            // Do something.
        }
    }

After Unity interface get message from ios, you can implement whatever you want.

Brian Choi
  • 733
  • 5
  • 14
  • https://stackoverflow.com/questions/58619463/android-changing-unity-scene-from-ui-components-outside-the-scene it looks same purpose but link is for Android. – Brian Choi Nov 03 '19 at 17:19