Last active
January 12, 2022 08:27
-
-
Save superbderrick/c49d842a0f14e6c8db62be94dd0f9ad3 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
func initUnity() { | |
if let nativeWindow = self.window { | |
if unityIsInitialized() { | |
UnitySampleUtils.showAlert(Constants.ERRORMESSAGES.ALREADY_INIT, Constants.ERRORMESSAGES.UNLOAD_FIREST, window: nativeWindow) | |
return | |
} | |
if didQuit { | |
UnitySampleUtils.showAlert(Constants.ERRORMESSAGES.CANNOTBE_INITIALIZED, Constants.ERRORMESSAGES.USE_UNLOAD, window:nativeWindow) | |
return | |
} | |
} | |
self.unityFramework = getUnityFramework() | |
if let unityframework = self.unityFramework { | |
unityframework.setDataBundleId("com.unity3d.framework") | |
unityframework.register(self) | |
NSClassFromString("FrameworkLibAPI")?.registerAPIforNativeCalls(self) | |
unityframework.runEmbedded(withArgc: CommandLine.argc, argv: CommandLine.unsafeArgv, appLaunchOpts: appLaunchOpts) | |
attachUnityView() | |
} | |
} | |
func attachUnityView() { | |
guard let unityRootView = unityFramework?.appController()?.rootView else { | |
return | |
} | |
self.unitySampleView = UnityUIView(frame: UIScreen.main.bounds) | |
unityRootView.addSubview(self.unitySampleView) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment