Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Integration Unity as a library in native iOS app

Discussion in '2019.3 Beta' started by PavelLU, May 27, 2019.

  1. lawinww

    lawinww

    Joined:
    Mar 20, 2019
    Posts:
    3
    @Instinct , You can temporary solve that UnloadApplication crash issue is that just wait the main thread about one or two second after quitting from unity to native IOS and then call unloadApplication(true).eg.
    DispatchQueue.main.asyncAfter(deadline: .now() + 1) {

    ufw.unloadApplication(true)

    }

    It will solved the problem.But I can't find a solution yet about unloadApplication(false) crash issue..
     
  2. Querke

    Querke

    Joined:
    Feb 21, 2013
    Posts:
    54
    Hmm ok, thanks for the help. However. You said "wait one or two seconds after quitting from unity to native iOS, then call unloadApplication(true)"...
    How do you "quit" form unity to native iOS then? :O
     
  3. lawinww

    lawinww

    Joined:
    Mar 20, 2019
    Posts:
    3
    There is IOS plugin to call a quit event to IOS like bridging C++ to Obj-c in my unity project. When I receive the quit event at native side, I removed the Unity window and call the unloadApplication(true).But I have an issue too that there is black screen appeared over screen window after quiting the unity and try to relaunch.
     
  4. megatcorleone

    megatcorleone

    Joined:
    Aug 14, 2019
    Posts:
    2
    I hit with this error the first time i tried out to test my built framework..
    You have to connect unityContainerView to your storyboard UIView. It is common thought how unity view being rendered right? Try to follow this guide.. check on the very last steps on how to fix your issue there.. https://www.kodbiro.com/blog/a-great-way-to-integrate-unity-into-the-native-ios-app/
     
    createtheimaginable likes this.
  5. megatcorleone

    megatcorleone

    Joined:
    Aug 14, 2019
    Posts:
    2
    Try to see my answer somewhere here.. my bad i couldnt even know how to redirect my answer inside this reply..
     
  6. KrisNicholsonCF

    KrisNicholsonCF

    Joined:
    Oct 2, 2016
    Posts:
    1
    We are also having problems after Unloading Unity using the sample project and `unloadApplicaion: false`. If we press the "Show Unity" button immediately after unloading we get an exception in [UnityView safeAreaInsetsDidChange]. This points to Unity not fully cleaning up after itself. We won't be able to use Unity as a Library unless this can be fixed or worked around. We need to be able to fully clean up Unity so it is no longer using memory.
     
    AbsAlx likes this.
  7. leetal

    leetal

    Joined:
    Aug 30, 2019
    Posts:
    1
    As some other here, after "unloading" Unity, it still receives events due to UnityAppController not deallocating properly when allowReload is false. And if doing this in the wrong order, like hiding the Unity window too early when unloading, can actually cause the main thread to go banans and consume around 60-80% CPU for a while.
     
    Last edited: Aug 30, 2019
    AbsAlx and KrisNicholsonCF like this.
  8. dvapps

    dvapps

    Joined:
    Apr 16, 2019
    Posts:
    5
    Hi,

    I use unity 2019.3.b1 and crash when send pause/resume the player. Attach the screen with the crash.

    BR

    J
     

    Attached Files:

  9. Querke

    Querke

    Joined:
    Feb 21, 2013
    Posts:
    54
    Hey!
    One issue I cannot solve, is to set the orientation of the Unity library to different settings than the native app.

    Example: I want the native app to be in portrait only, no problem. But I want the Unity library to be in landscape (left or right). Here is the issue. The native app controls the orientation for both the native view and the unity view.
    • I have tried to disable different orientation in Unity player build settings, with no effect.
    • I have tried to set the "Screen.orientation = " in C# within Unity on startup. With no effect.
    • I have tried setting the orientations in the info tab on Unity-iPhone target (info.plist in the unity-iphone root xcode proj)
    • I have tried setting the orientations in the info tab on UnityFramework target (info.plist in the UnityFramework sub-folder)

    No matter what I try to do. The orientation is controlled by what is set in the Native app plist.

    Any way to achieve what I am trying to do? (Native app view = portrait, Unity lib view = landscape) @IevaUnity @PavelLU
     
    gaolei_nls likes this.
  10. i4mtheone

    i4mtheone

    Joined:
    May 16, 2018
    Posts:
    11
    Hi!

    Is it possible to run a specific unity scene (is there any parameter for it)? Or will it always load index 0, meaning, I would have to implement some kind of a bridge plugin to set desired launch scene and actually load it from the main scene that starts as a first one?
     
  11. rwetzler779

    rwetzler779

    Joined:
    Mar 9, 2019
    Posts:
    4
    I would also like to know if this is a possibility, as I am trying to make a menu in Swift that will control the functionality of the Unity app upon launch
     
  12. rwetzler779

    rwetzler779

    Joined:
    Mar 9, 2019
    Posts:
    4
    I have an answer for you! After working on this myself all day I finally got it working. It's a little bit of a hacky workaround, as I couldn't find a way to do it with a parameter.

    So, how I did it was I made a text file in a common location that both Swift and Unity could read from. In Swift, I saved a number in this text file that corresponds to what Unity scene the user wants to load. The location that this text file is in is very important:

    In Swift: Have your script create and save your text file (e.g "SceneToOpen.txt") in the documents directory. Pretty much just call this function in your viewController file before you launch the game (Note the use of my helper method, getDocumentsDirectory. It's not necessary, just makes things neater):
    Code (Swift):
    1. func StartLevel(level: String){
    2.         let filename = getDocumentsDirectory().appendingPathComponent("SceneToOpen.txt")
    3.         do {
    4.             try level.write(to: filename, atomically: true, encoding: String.Encoding.utf8)
    5.             self.textBox.text = filename.path
    6.         } catch {
    7.            //Error Handling
    8.         }
    9.     }
    10. func getDocumentsDirectory() -> URL {
    11.  
    12.         let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
    13.  
    14.         return paths[0]
    15.  
    16.     }
    17.  
    Then, in Unity, make a new Scene and in your BuildSettings add this scene to the first spot. In this scene add an empty GameObject and attach to it a Script component, which will read from this same text file. As it turns out, Unity's Application.persistentDataPath gives you the same documents directory as we had accessed in Swift. This is all you need in the script:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using System.IO;
    4. using UnityEngine;
    5. using UnityEngine.SceneManagement;
    6.  
    7.  
    8. public class SceneOpener : MonoBehaviour
    9. {
    10.     // Start is called before the first frame update
    11.     void Start()
    12.     {
    13.         string path = Application.persistentDataPath;
    14.         try
    15.         {
    16.             StreamReader sceneStream = new StreamReader(path + "/SceneToOpen.txt");
    17.             int nextScene = 0;
    18.             if (!sceneStream.EndOfStream)
    19.             {
    20.                 nextScene = int.Parse(sceneStream.ReadLine());
    21.             }
    22.             switch (nextScene)
    23.             {
    24.                 case 1:
    25.                     SceneManager.LoadScene("Scene 1");
    26.                     break;
    27.                 case 2:
    28.                     SceneManager.LoadScene("Scene 2");
    29.                     break;
    30.                 case 3:
    31.                     SceneManager.LoadScene("Scene 3");
    32.                     break;
    33.                 default:
    34.                     SceneManager.LoadScene("Menu Scene");
    35.                     break;
    36.             }
    37.             sceneStream.Close();
    38.         }
    39.         catch (System.Exception)
    40.         {
    41.  
    42.         }
    43.     }
    I hope this helps. Sometimes, the empty first scene displays for a few seconds before switching. It'd be nice if this scene could look like a seamless transition. That's something that could be worked on.
     
    -chris likes this.
  13. NSWell

    NSWell

    Joined:
    Jul 30, 2017
    Posts:
    89
    @PavelLU Hi, I added some native buttons (Swift) in the unity view. The buttons was displayed in the screen view, but the buttons can't interact, and clicking on them doesn't happen. I tried the Swift UI with Unity as Library , they can display the unity view but unity module was working. Are there any ideas?
     
    elhongo likes this.
  14. DirkDenzer

    DirkDenzer

    Joined:
    May 8, 2019
    Posts:
    11
    I'm facing the same issue with the black screen on resume, did you ever manage to find the reason and or a solution for this?

    Well it seems the black comes due to the call to
    UnityLoadApplicationFromSceneLessState();
    because if I skip that, it isn't black anymore. But then it is frozen...
     
    Last edited: Oct 2, 2019
  15. Aiursrage2k

    Aiursrage2k

    Joined:
    Nov 1, 2009
    Posts:
    4,835
    Are you guys going to do one for react-native so that it can work on both IOS and android without having to create 2 different uis

    There is this one but it didnt work and would be better if unity added an offical
    https://www.npmjs.com/package/react-native-unity-view
     
    chairmin likes this.
  16. gaolei_nls

    gaolei_nls

    Joined:
    Aug 26, 2019
    Posts:
    2
    I'm also facing the exact same problem here. Any workaround or progress on a fix?
     
  17. charmcrescini

    charmcrescini

    Joined:
    Sep 9, 2019
    Posts:
    18
    Is this possible if I want to apply AR foundation on my unity project?
     
  18. NSWell

    NSWell

    Joined:
    Jul 30, 2017
    Posts:
    89
    It's okay , I tried
     
    charmcrescini likes this.
  19. charmcrescini

    charmcrescini

    Joined:
    Sep 9, 2019
    Posts:
    18
    T
    Apparently the unity view does not show when I press init button.
     
  20. Querke

    Querke

    Joined:
    Feb 21, 2013
    Posts:
    54
    Rewrote my swift integration file. You can now Init/Show Unity, Hide Unity, Unload Unity, Send message to game object.

    Here is the updated script (Add this file into the swift xcode project):

    Code (Boo):
    1. //
    2. //  Created by Simon Tysland on 19/08/2019.
    3. //
    4. import Foundation
    5. import UnityFramework
    6.  
    7. class UnityEmbeddedSwift: UIResponder, UIApplicationDelegate, UnityFrameworkListener, NativeCallsProtocol {
    8.  
    9.     private struct UnityMessage {
    10.         let objectName : String?
    11.         let methodName : String?
    12.         let messageBody : String?
    13.     }
    14.  
    15.     private static var instance : UnityEmbeddedSwift!
    16.     private var ufw : UnityFramework!
    17.     private static var hostMainWindow : UIWindow! //Window to return to when exitting Unity window
    18.     private static var launchOpts : [UIApplication.LaunchOptionsKey: Any]?
    19.  
    20.     private static var cachedMessages = [UnityMessage]()
    21.  
    22.     //Static functions that can be called from other scripts
    23.     static func setHostMainWindow(_ hostMainWindow : UIWindow?) {
    24.         UnityEmbeddedSwift.hostMainWindow = hostMainWindow
    25.         let value = UIInterfaceOrientation.landscapeLeft.rawValue
    26.         UIDevice.current.setValue(value, forKey: "orientation")
    27.    
    28.     }
    29.  
    30.     static func setLaunchinOptions(_ launchingOptions :  [UIApplication.LaunchOptionsKey: Any]?) {
    31.         UnityEmbeddedSwift.launchOpts = launchingOptions
    32.     }
    33.  
    34.     static func showUnity() {
    35.         if(UnityEmbeddedSwift.instance == nil || UnityEmbeddedSwift.instance.unityIsInitialized() == false) {
    36.             UnityEmbeddedSwift().initUnityWindow()
    37.         }
    38.         else {
    39.             UnityEmbeddedSwift.instance.showUnityWindow()
    40.         }
    41.     }
    42.  
    43.     static func hideUnity() {
    44.         UnityEmbeddedSwift.instance?.hideUnityWindow()
    45.     }
    46.  
    47.     static func unloadUnity() {
    48.         UnityEmbeddedSwift.instance?.unloadUnityWindow()
    49.     }
    50.  
    51.     static func sendUnityMessage(_ objectName : String, methodName : String, message : String) {
    52.         let msg : UnityMessage = UnityMessage(objectName: objectName, methodName: methodName, messageBody: message)
    53.    
    54.    
    55.         //Send the message right away if Unity is initialized, else cache it
    56.         if(UnityEmbeddedSwift.instance != nil && UnityEmbeddedSwift.instance.unityIsInitialized()) {
    57.             UnityEmbeddedSwift.instance.ufw.sendMessageToGO(withName: msg.objectName, functionName: msg.methodName, message: msg.messageBody)
    58.         }
    59.         else {
    60.             UnityEmbeddedSwift.cachedMessages.append(msg)
    61.         }
    62.     }
    63.  
    64.     //Callback from UnityFrameworkListener
    65.     func unityDidUnload(_ notification: Notification!) {
    66.         ufw.unregisterFrameworkListener(self)
    67.         ufw = nil
    68.         UnityEmbeddedSwift.hostMainWindow?.makeKeyAndVisible()
    69.     }
    70.  
    71.     //Private functions called within the class
    72.     private func unityIsInitialized() -> Bool {
    73.         return ufw != nil && (ufw.appController() != nil)
    74.     }
    75.  
    76.     private func initUnityWindow() {
    77.         if unityIsInitialized() {
    78.             showUnityWindow()
    79.             return
    80.         }
    81.    
    82.         ufw = UnityFrameworkLoad()!
    83.         ufw.setDataBundleId("com.unity3d.framework")
    84.         ufw.register(self)
    85.         NSClassFromString("FrameworkLibAPI")?.registerAPIforNativeCalls(self)
    86.    
    87.         ufw.runEmbedded(withArgc: CommandLine.argc, argv: CommandLine.unsafeArgv, appLaunchOpts: UnityEmbeddedSwift.launchOpts)
    88.    
    89.         sendUnityMessageToGameObject()
    90.    
    91.         UnityEmbeddedSwift.instance = self
    92.     }
    93.  
    94.     private func showUnityWindow() {
    95.         if unityIsInitialized() {
    96.             ufw.showUnityWindow()
    97.             sendUnityMessageToGameObject()
    98.         }
    99.     }
    100.  
    101.     private func hideUnityWindow() {
    102.         if(UnityEmbeddedSwift.hostMainWindow == nil) {
    103.             print("WARNING: hostMainWindow is nil! Cannot switch from Unity window to previous window")
    104.         }
    105.         else {
    106.             UnityEmbeddedSwift.hostMainWindow?.makeKeyAndVisible()
    107.         }
    108.     }
    109.  
    110.     private func unloadUnityWindow() {
    111.         if unityIsInitialized() {
    112.             UnityEmbeddedSwift.cachedMessages.removeAll()
    113.             ufw.unloadApplication(true)
    114.         }
    115.     }
    116.  
    117.     private func sendUnityMessageToGameObject() {
    118.         if(UnityEmbeddedSwift.cachedMessages.count >= 0 && unityIsInitialized())
    119.         {
    120.             for msg in UnityEmbeddedSwift.cachedMessages {
    121.                 ufw.sendMessageToGO(withName: msg.objectName, functionName: msg.methodName, message: msg.messageBody)
    122.             }
    123.        
    124.             UnityEmbeddedSwift.cachedMessages.removeAll()
    125.         }
    126.     }
    127.  
    128.     private func UnityFrameworkLoad() -> UnityFramework? {
    129.         let bundlePath: String = Bundle.main.bundlePath + "/Frameworks/UnityFramework.framework"
    130.    
    131.         let bundle = Bundle(path: bundlePath )
    132.         if bundle?.isLoaded == false {
    133.             bundle?.load()
    134.         }
    135.    
    136.         let ufw = bundle?.principalClass?.getInstance()
    137.         if ufw?.appController() == nil {
    138.             // unity is not initialized
    139.             //            ufw?.executeHeader = &mh_execute_header
    140.        
    141.             let machineHeader = UnsafeMutablePointer<MachHeader>.allocate(capacity: 1)
    142.             machineHeader.pointee = _mh_execute_header
    143.        
    144.             ufw!.setExecuteHeader(machineHeader)
    145.         }
    146.         return ufw
    147.     }
    148. }

    Set initial values for Unity Embedded Player
    • UnityEmbeddedSwift.setHostMainWindow(window)
      • This method should pass the window that the unity player should go back to when exiting the unity player
    • UnityEmbeddedSwift.setLaunchingOptions(launchOptions)
      • Pass the launching options from the application function in AppDelegate
    • Code (Boo):
      1.  
      2. @UIApplicationMain
      3. class AppDelegate: UIResponder, UIApplicationDelegate {
      4.  
      5.    var window: UIWindow?
      6.  
      7.    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
      8.       // Override point for customization after application launch.
      9.       UnityEmbeddedSwift.setHostMainWindow(window)
      10.       UnityEmbeddedSwift.setLaunchinOptions(launchOptions)
      11.       return true
      12.    }
      13.   ...
      14. }
      15.  

    Show/Initialize Unity embedded player
    • UnityEmbeddedSwift.showUnity()
    • Will initialize the Unity embedded player. If already initialized, it will just show the Unity window

    Hide Unity embedded player
    • UnityEmbeddedSwift.hideUnity()

    Unload Unity embedded player:
    • UnityEmbeddedSwift.unloadUnity()

    Send message to Unity library:
    • UnityEmbeddedSwift.sendUnityMessage(“ObjectName”, “MethodName” “Params”)
    • NOTE: If unity player is not initialized, the message will be stored and called next time Unity is loaded. If not the message is sent right away
    Calling stuff from Unity (C#) to xcode (Swift)
    • Here we are going to use the included NativeCallProxy files that was included in the original tutorial (1st post in this thread). In these files we can define the methods we want to call. (Some obj-c knowledge required. Look at the "showHostMainWindow" method that in the NativeCallProxy files to understand how this is done).
    • Remember, the obj-c "NativeCallProxy" files need to be added under Plugins/iOS folder).
    • The methods created in the Obj-C files need to be accessible in C#. To do this, define them as such:
      Code (CSharp):
      1. public class NativeAPI
      2. {
      3.     [DllImport("__Internal")]
      4.     public static extern void youMethodHere();
      5. }
    • When this method is called in C#, it calls the method in the obj-c files. And we can "hijack" this method in our swift file. To do this, we need a bridging header and implement the method in our swift file.
    • To call stuff from C# to swift, you need to create a Obj-c to swift bridging header. This is easy:
      1. Follow this guide, to automatically create the bridging header:
        1. https://intelligentbee.com/2017/08/14/create-bridging-header-ios/
        2. (Just delete the Obj-c file you just created)
      2. If bridging header wasn’t created automatically, follow this guide: https://mycodetips.com/ios/manually-adding-swift-bridging-header-1290.html
    • Inside the bridging header file, add this line:
      1. #import <UnityFramework/NativeCallProxy.h>
    • Now, you can implement your methods in the swift file. I have already implemented the NativeCallProxy in the swift script. See behind the class name in the swift file, where I am deriving from NativeCallProxy.
     
    Last edited: Oct 8, 2019
  21. Querke

    Querke

    Joined:
    Feb 21, 2013
    Posts:
    54
    khaled24 likes this.
  22. bambamyi

    bambamyi

    Joined:
    Nov 26, 2008
    Posts:
    90
  23. Querke

    Querke

    Joined:
    Feb 21, 2013
    Posts:
    54
    Getting xcode to find the unityframework is sometimes tricky.

    Add “UnityFramework” as “Embedded Binaries” in swift xcode project.
    Remove the UnityFramework from the Linked Frameworks and libraries list.
    I usually do a quick build now, to build the UnityFramework.
    If UnityEmbeddedSwift doesn’t find UnityFramework, do the following: 1. Switch target from native app to UnityFramework 2. Clean project (cmd + shift + k) 3. Do a build (cmd + b) 4. Switch back to native app, do another build
     
  24. bambamyi

    bambamyi

    Joined:
    Nov 26, 2008
    Posts:
    90
    Thanks for quick reply. I will try it :)
     
  25. bambamyi

    bambamyi

    Joined:
    Nov 26, 2008
    Posts:
    90
    So I have tried this... unless I am missing something, it still seems to be a problem. Can it be that we need a obj-c to swift bridge file?
     
  26. bambamyi

    bambamyi

    Joined:
    Nov 26, 2008
    Posts:
    90
    I got it working! thanks!
     
  27. Querke

    Querke

    Joined:
    Feb 21, 2013
    Posts:
    54
    I am just guessing now, but maybe you don't have a working bridging header file (check my steps how to create one). Maybe it has something to do that you haven't implemented the methods from the NativeCallProxy file into the swift file? For example the (void) showHostMainWindow method.
     
  28. charmcrescini

    charmcrescini

    Joined:
    Sep 9, 2019
    Posts:
    18
    Hello. I tried this but the unity window does not show on my end. Do you know the reason why? Thanks in advance.
     
  29. charmcrescini

    charmcrescini

    Joined:
    Sep 9, 2019
    Posts:
    18
    After trying multiple times, for some reason it just worked when I built it on a device. Thanks though! :)
     
  30. charmcrescini

    charmcrescini

    Joined:
    Sep 9, 2019
    Posts:
    18
    I think the problem is I am getting error when inserting the setHostMainWindow
     

    Attached Files:

  31. Querke

    Querke

    Joined:
    Feb 21, 2013
    Posts:
    54
    Oh yes. I had to plugin a physical device in order to get it working as well. Dont know why
     
    tjones12 likes this.
  32. Querke

    Querke

    Joined:
    Feb 21, 2013
    Posts:
    54
    You have to define the UIWindow, like so:
    Code (Boo):
    1. @UIApplicationMain
    2. class AppDelegate: UIResponder, UIApplicationDelegate {
    3.  
    4.    var window: UIWindow?
    5.  
    6.    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    7.        // Override point for customization after application launch.
    8.        UnityEmbeddedSwift.setHostMainWindow(window)
    9.        UnityEmbeddedSwift.setLaunchinOptions(launchOptions)
    10.        return true
    11.    }
    12.   ...
    13. }
    Changing my answer to this
     
    charmcrescini likes this.
  33. charmcrescini

    charmcrescini

    Joined:
    Sep 9, 2019
    Posts:
    18
    Hello, Sorry for the trouble but it still does not show the unity window. I just put a button that calls the function
    UnityEmbeddedSwift.showUnity().
     
  34. Querke

    Querke

    Joined:
    Feb 21, 2013
    Posts:
    54
    Do you receive any errors? Did you follow the original tutorial (made by Unity official devs)?
     
  35. bambamyi

    bambamyi

    Joined:
    Nov 26, 2008
    Posts:
    90
    I am seeing the same thing. No unity window.
     
  36. charmcrescini

    charmcrescini

    Joined:
    Sep 9, 2019
    Posts:
    18
    No errors. It just doesn't launch the Unity window.
     
  37. bambamyi

    bambamyi

    Joined:
    Nov 26, 2008
    Posts:
    90
    So I can tell that there are stuff happening with the unity side because i see debug logs coming in. There are no errors showing up and the ufw window just does not show up.

    YI, the objective c version works just fine. This is whole new project and it is created just for the swift version. Thanks in advance. I am going to continue to play with this. I will let you guys know if I find anything.
     
    arcade_jon and charmcrescini like this.
  38. dhruvmodhapp

    dhruvmodhapp

    Joined:
    Sep 20, 2018
    Posts:
    3
    I have used an image target example scene of AR-Foundation 2.1 in the unity app. After integrated it to native app. It showing a camera but image tracking not working.
    Does anybody have a solution?
     
  39. bambamyi

    bambamyi

    Joined:
    Nov 26, 2008
    Posts:
    90
    I would make sure it works by itself first and then try the integration. :)
     
  40. arcade_jon

    arcade_jon

    Joined:
    Feb 9, 2018
    Posts:
    11
    Exactly the same problem for me - I can see Unity starting in the Xcode log, but nothing showing on the screen.
     
  41. bambamyi

    bambamyi

    Joined:
    Nov 26, 2008
    Posts:
    90
    So looks like the author of the embeddedswift is out of the conversation. I poked into this myself bit deeper and finally got it to work. One thing I did notice was that the UnityFramework's view briefly shows up but it goes to the back instantly... when I checked the UIView hierarchy, I didn't even see the viewcontroller created by the UnityFramework.
    One solution for this weird behavior was to expose the uiview of the unity framework and add it as subview of the view of the viewcontroller that I was calling from.
     
  42. arcade_jon

    arcade_jon

    Joined:
    Feb 9, 2018
    Posts:
    11
    Thanks bambamyi - would you mind telling me how to expose the uiview of the unity framework and add it as subview of the view of the viewcontroller. Sorry - I only dip into Xcode when forced out of my safe Unity world every few months!
     
  43. Querke

    Querke

    Joined:
    Feb 21, 2013
    Posts:
    54
  44. bambamyi

    bambamyi

    Joined:
    Nov 26, 2008
    Posts:
    90
    Hello sorry for the late reply. You can grab the view that the unityframework creates like so:

    self.unityView = self.ufw.appController()?.rootView;

    However, the route I took ran into some snags when trying to unload the unity. I think there is a problem originating from the framework when working with swift because when you tell unityframework to runEmbedded, the unity window just loads and disappears. Anyways, I will let you know what I find out.
     
    arcade_jon likes this.
  45. bambamyi

    bambamyi

    Joined:
    Nov 26, 2008
    Posts:
    90
    Hey buddy. I am sorry that I made a bad assumption. :) Thanks for the document, it really is helpful. Could you tell me if you are having an issue with the unity window loading and closing immediately?
     
  46. bambamyi

    bambamyi

    Joined:
    Nov 26, 2008
    Posts:
    90
    Hey it is me again. I forgot to ask you. I am assuming that your unity window is showing up? It looks like there are number of us running into this issue. It definitely is not your code but it probably on the unity's side. I don't particularly like the way they stuffed everything into one file... I really like your approach. Could you possibly share some more information. Is there something else you are doing? Thank you in advance.
     
  47. NSWell

    NSWell

    Joined:
    Jul 30, 2017
    Posts:
    89
    Emmm. If your Unity view does not showing , u can try this code

    self.navigationController?.pushViewController(ufw.appController().rootViewController, animated: true)

    It will be showing. But There are some problems.

    I think this is a problem with the new XCode or Unity . I was using XCode 11.0 (11A420a).
     
    Spicyruby likes this.
  48. bambamyi

    bambamyi

    Joined:
    Nov 26, 2008
    Posts:
    90
    Thank you for the tip! As you are pointing out, it could be the new Xcode or the unity's implementation.
     
  49. bambamyi

    bambamyi

    Joined:
    Nov 26, 2008
    Posts:
    90
    So instead of using the view method. I used the viewcontroller method and it works. I just need to make sure unloading works now... cheers!
     
  50. lee_unity808

    lee_unity808

    Joined:
    Jan 19, 2018
    Posts:
    1
    Guys I can't get the Unity window to show on iOS 13 - works fine prior to that - For AR Image markers to work you have to add the Images.xcassets file to your project.