obsidian/笔记文件/2.笔记/UnityGetGLViewController.md
2025-03-26 00:02:56 +08:00

10 lines
964 B
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ios
#unity
UnityGetGLViewController是Unity在iOS平台上的一个关键函数用于获取Unity应用的根视图控制器。以下是关于UnityGetGLViewController的详细解释
功能UnityGetGLViewController函数返回Unity应用的根视图控制器UIViewController。这个根控制器上的视图是Unity的视图即将Unity界面显示在手机上的基础。
用途在接入广告SDK或需要在Unity界面上覆盖原生UI控件时经常需要用到UnityGetGLViewController。例如在Unity界面上打开一个原生的UIWebView就需要获取当前的Unity视图控制器并添加子页面和子控制器。
实现在UnityAppController.mm文件中UnityGetGLViewController通过调用GetAppController()获取UIApplication的单例类然后返回其rootViewController。
综上所述UnityGetGLViewController是Unity与iOS平台交互时获取Unity视图控制器的重要函数。