gpt4 book ai didi

ios - 在 Objective C 代码中以 View 形式访问 Unity 3d UI 组件(例如面板/图像)

转载 作者:行者123 更新时间:2023-11-29 05:21:10 25 4
gpt4 key购买 nike

我有一个特定的任务,我想将 UIView 传递到我的 iOS 项目中的 SDK 之一。现在,我的项目是在 Unity 3d 中构建的简单 2D 游戏。我想将 Canvas 中的面板作为 UIView 发送到该 SDK。

我了解 iOS 和 Unity 通信。它发生在使用 Char* 时。

我不确定如何在 iOS 代码中将 GameObject Panel 作为 UIView 访问。如果我在这方面得到任何帮助,我将非常感激。

最佳答案

上面是您可以从 ios 界面访问的解决方案之一,但在看到这个之前,请阅读 https://docs.unity3d.com/Manual/PluginsForIOS.html .它将有助于理解 Unity 和 native 代码如何通信。

iOS:测试.mm

#import "Unity/UnityInterface.h"

...
...

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

Unity:Commnicator.cs、MessageGameCommunicator(游戏对象名称)

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

Unity接口(interface)从ios获取消息后,你可以实现任何你想要的。

关于ios - 在 Objective C 代码中以 View 形式访问 Unity 3d UI 组件(例如面板/图像),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58679690/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com