Last active
February 23, 2022 11:49
-
-
Save eunjin3786/0d7e47d89bbe41ce25ebddc09a9b0067 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
import Foundation | |
import UnityFramework | |
class UnityManager: NSObject { | |
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) | |
✅ NSClassFromString("FrameworkLibAPI")?.registerAPIforNativeCalls(self) | |
ufw.runEmbedded( | |
withArgc: CommandLine.argc, | |
argv: CommandLine.unsafeArgv, | |
appLaunchOpts: nil | |
) | |
} | |
} | |
... | |
} | |
// From Unity | |
extension UnityManager: NativeCallsProtocol { | |
func sendMessage(toMobileApp message: String!) { | |
print(message) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment