Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by oliver-jones · Sep 10, 2013 at 03:51 PM · iosviewnative

Unity iOS - Launch Native Window Instead of Unity

Hello,

When you build your Unity Application for iOS - it builds an Xcode project, in which the Unity app runs ontop of xcode. Because of this, I want to know if its possible to build a page natively within the Unity-Xcode project with a button, then when pressed will then launch the unity application:

alt text

Forgive my lack of understanding in the matter, but I imagine there would be a file within the Unity-Xcode that controls which files to launch during startup (in this case, its all the Unity files). Could I not modify this file, so it will only launch a 'View', with a button. Then when the button is pressed - to launch the Unity files, etc.

Thanks, Ollie.

ss.png (52.7 kB)
Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image oliver-jones · Sep 12, 2013 at 08:20 AM 0
Share
  • bump **

avatar image oliver-jones · Sep 13, 2013 at 08:11 PM 0
Share
  • bump bump bump ** :)

avatar image ShadoX · Sep 13, 2013 at 11:13 PM 0
Share

Any chance that http://docs.unity3d.com/Documentation/$$anonymous$$anual/StructureOfXcodeProject.html or http://answers.unity3d.com/questions/407643/edit-xcode-build-files-through-unity-script.html might help?

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by jacksmash2012 · Sep 20, 2013 at 07:15 PM

If you are running Unity 4.2, then you can simply subclass the UnityAppController and assign the UnityView property to the UIView of your choosing. You just have to be sure to have the following at the bottom of your implementing class:

 IMPL_APP_CONTROLLER_SUBCLASS(MyAppController)

Then, make sure you override the createViewHierarchyImpl function. For example:

 - (void)createViewHierarchyImpl
 {
     SomeViewController *someVC = [[SomeViewController alloc] initWithNibName:@"SomeViewController" bundle:nil];
     _rootController = someVC;
     _rootView       = someVC.view;
 }

You really shouldn't have to change the main.mm class at all.

HTH.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by dannyskim · Sep 14, 2013 at 04:45 AM

This is a pretty complicated question. It's possible, but instead of wording in the sense that you're "launching unity," you're actually just adding the UIViewcontroller exposed through the UnityAppController.h and UnityAppController.mm files.

As you can see from the aforementioned XCode files:

 - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
 {
     printf_console("-> applicationDidFinishLaunching()\n");
     // get local notification
     if (&UIApplicationLaunchOptionsLocalNotificationKey != nil)
     {
         UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
         if (notification)
             UnitySendLocalNotification(notification);
         }
 
     // get remote notification
     if (&UIApplicationLaunchOptionsRemoteNotificationKey != nil)
     {
         NSDictionary *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
         if (notification)
             UnitySendRemoteNotification(notification);
         }
 
     if ([UIDevice currentDevice].generatesDeviceOrientationNotifications == NO)
         [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
 
     [DisplayManager Initialize];
     _mainDisplay = [[DisplayManager Instance] mainDisplay];
     [_mainDisplay createView:YES showRightAway:NO];
 
     [KeyboardDelegate Initialize];
     CreateViewHierarchy();
 
     [self performSelector:@selector(startUnity:) withObject:application afterDelay:0];
 
     return NO;
 }

is where Unity is setup within the context of an iOS application. The way that I have done it, is to make a separate AppDelegate, subclass it from UnityAppController, and set the name of the AppDelegate accordingly in the main.mm file generated by Unity after build to XCode:

 #import <UIKit/UIKit.h>
 
 #include "RegisterClasses.h"
 #include "RegisterMonoModules.h"
 
 // Hack to work around iOS SDK 4.3 linker problem
 // we need at least one __TEXT, __const section entry in main application .o files
 // to get this section emitted at right time and so avoid LC_ENCRYPTION_INFO size miscalculation
 static const int constsection = 0;
 bool UnityParseCommandLine(int argc, char *argv[]);
 void UnityInitTrampoline();
 
 
 // WARNING: this MUST be c decl (NSString ctor will be called after +load, so we cant really change its value)
 const char* AppControllerClassName = "YourAppDelegateClassNameHere";
 
 
 int main(int argc, char *argv[])
 {
     NSAutoreleasePool* pool = [NSAutoreleasePool new];
 
     UnityInitTrampoline();
     if(!UnityParseCommandLine(argc, argv))
         return -1;
 
     RegisterMonoModules();
     NSLog(@"-> registered mono modules %p\n", &constsection);
 
     UIApplicationMain(argc, argv, nil, [NSString stringWithUTF8String:AppControllerClassName]);
 
     [pool release];
     return 0;
 }

That should get you started.

After this setup is done, you're basically forwarding Unity's view controller into a completely new AppDelegate class, and thus, a basically fresh UIKit application. You set your own rootViewController and the rootView of the shared application's window, and everything after that is just like regular old Cocoa Touch coding.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by madhur · Nov 09, 2013 at 06:55 AM

I think this thread will be useful for you. I'm also having the same requirement. Finally found this. http://forum.unity3d.com/threads/191971-Unity-AppController-subclassing

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

Start a Unity app from inside a native iOS app 8 Answers

iOS - Difference Between Location & GPS Plugin 0 Answers

What is the best way to integrate native XCODE 0 Answers

Existing Native app, put Unity in as a subview 4 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges