Search Unity

Feedback Integrating Unity game view inside a Native iOS Application view

Discussion in 'General Discussion' started by unity_95ICPFwaui8-ZQ, May 28, 2019.

  1. unity_95ICPFwaui8-ZQ

    unity_95ICPFwaui8-ZQ

    Joined:
    May 27, 2019
    Posts:
    3
    I would like to know whether my approach to integrate unity game in native iOS application is good enough and will not face issues going further with the same.
    1. Built the UnityFramework target in the iOS application exported from the Unity game.
    2. Added the framework in the existing native iOS application
    3. Added the required User-defined settings in the existing native iOS application's build settings
    4. In the existing application viewController's button action method, called the below method to launch the unity window.

    [[UnityFramework getInstance] runEmbeddedWithArgc:args.count argv:cargs appLaunchOpts:mad:{}];

    5. Added a subclass for UnityAppController and in the preStartUnity method resized the window.
    Eg.
    -(void) preStartUnity {

    [self.window setFrame:CGRectMake(0, 0, 150, 150)];

    }
    Any suggestions on dismissing the view. For now, I did
    [[UnityFramework getInstance] unloadApplicaion:YES]; + UnityAppController.window hidden and then called showUnityWindow to display the game again.
    Also, incase if I need to access any app delegate functionalities I can call them from my existing AppDelegate to the UnityAppController subclass
    Please let me know, if there are any simple and better approaches for integration
     
    Last edited: May 28, 2019
  2. Aiursrage2k

    Aiursrage2k

    Joined:
    Nov 1, 2009
    Posts:
    4,835
    Yeah this is a nightmare and the solution keeps changing
     
  3. samizzo

    samizzo

    Joined:
    Sep 7, 2011
    Posts:
    487
    I haven't tried the new UnityFramework feature but it sounds promising. A few years ago I did this in Unity 5.2.1. Here's a prototype I built to demonstrate it: https://github.com/samizzo/UnityNativePrototype I don't know if my prototype still works but the fundamentals should be good I think. Anyway probably it's best to go with the UnityFramework stuff but I just thought I'd point out an alternative.
     
  4. unity_95ICPFwaui8-ZQ

    unity_95ICPFwaui8-ZQ

    Joined:
    May 27, 2019
    Posts:
    3
    Yeah exactly. Thats why thought to post and get a suggestion
     
  5. unity_95ICPFwaui8-ZQ

    unity_95ICPFwaui8-ZQ

    Joined:
    May 27, 2019
    Posts:
    3
    Thanks for the suggestion. Unity project that is built from the latest version looks different from the one which is posted in the GitHub link you provided.