Last active
February 24, 2022 06:29
-
-
Save eunjin3786/a802a4e9e7c384fec6b0090d92671259 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UnityManager: NSObject { | |
... | |
private var hostMainWindow : UIWindow? | |
func setHostMainWindow(_ hostMainWindow: UIWindow?) { | |
self.hostMainWindow = hostMainWindow | |
} | |
func launchUnity() { | |
let isInitialized = self.ufw?.appController() != nil | |
if isInitialized { | |
self.ufw?.showUnityWindow() | |
} else { | |
guard let ufw = self.loadUnityFramework() else { return } | |
self.ufw = ufw | |
ufw.setDataBundleId(dataBundleId) | |
✅ ufw.register(self) | |
ufw.runEmbedded( | |
withArgc: CommandLine.argc, | |
argv: CommandLine.unsafeArgv, | |
appLaunchOpts: nil | |
) | |
} | |
} | |
func closeUnity() { | |
self.ufw?.unloadApplication() | |
} | |
... | |
} | |
extension UnityManager: UnityFrameworkListener { | |
func unityDidUnload(_ notification: Notification!) { | |
self.ufw?.unregisterFrameworkListener(self) | |
self.ufw = nil | |
self.hostMainWindow?.makeKeyAndVisible() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment