【问题标题】:Error Building for Unity in Native iOS App在原生 iOS 应用程序中构建 Unity 时出错
【发布时间】:2018-12-28 04:41:20
【问题描述】:

我是 iOS 开发的初学者。 我想在 Native iOS App 示例中获得 Unity 的帮助。我经历了一些过时的在线课程,最后也显示了一些错误。我想询问是否有人可以发布视频教程或示例项目以在 Native iOS 应用程序中制作 Unity .. 这是示例链接:- https://medium.com/@IronEqual/how-to-embed-a-unity-game-into-an-ios-native-swift-app-772a0b65c82 就像这样..

【问题讨论】:

  • 你的错误是什么?
  • @Rurouni,我尝试了 10 多个示例项目,它总是显示一些错误,例如 PrecompileSwiftBridgeHeader failed with a nonzero exit code error 或 Clang。如果我再次清除那些会想出另一个.. 真的很难。你要求任何最新的视频或样本。
  • @Aleesha.... 显示错误的屏幕截图
  • @wings,真的很难找到合适的解决方案,只有构建你能找到的样本..
  • 尝试将所有 IDE 更新到最新版本

标签: c# swift xcode unity3d native


【解决方案1】:

根据您的要求,我上传了一个视频教程,用于使用最新版本的 Xcode-10.1 和 unity -2018.2.18f1 在 Native iOS App 中构建 Unity。

Youtube 链接-https://www.youtube.com/watch?v=DLkeGz5vCzk

App Delegate 的源代码是,

AppDelegate.h

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UIWindow *unityWindow;
@property (strong, nonatomic) UnityAppController *unityController;
- (void) showUnityWindow;
- (void) hideUnityWindow;


@end

AppDelegate.m

#import "AppDelegate.h"
#import "ViewController.h"
@interface AppDelegate ()

@end

@implementation AppDelegate
- (UIWindow *)unityWindow {
    return UnityGetMainWindow();
}
- (void) showUnityWindow {
    [self.unityWindow makeKeyAndVisible];
}
- (void) hideUnityWindow{
    [self.window makeKeyAndVisible];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

    self.window = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen]. bounds];

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    ViewController *mainVC = [storyboard instantiateViewControllerWithIdentifier:@"MainIdentity"];
    UINavigationController *naVC = [[UINavigationController alloc] initWithRootViewController:mainVC];
    self.window.rootViewController = naVC;
    self.unityController = [[UnityAppController alloc] init];
    [self.unityController application:application didFinishLaunchingWithOptions: launchOptions];

    return YES;

}


- (void)applicationWillResignActive:(UIApplication *)application {

    [self.unityController applicationWillResignActive:application];
}


- (void)applicationDidEnterBackground:(UIApplication *)application {

    [self.unityController applicationDidEnterBackground:application];
}


- (void)applicationWillEnterForeground:(UIApplication *)application {

    [self.unityController applicationWillEnterForeground:application];
}


- (void)applicationDidBecomeActive:(UIApplication *)application {

    [self.unityController applicationDidBecomeActive:application];
}


- (void)applicationWillTerminate:(UIApplication *)application {

    [self.unityController applicationWillTerminate:application];
}


@end

And View Controller.m

#import "ViewController.h"
#import "AppDelegate.h"

@interface ViewController ()
@property (nonatomic) BOOL isShowUnityWindow;
- (IBAction)showUnityTouched:(id)sender;
@property (weak, nonatomic) IBOutlet UIView *unityViewStart;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.isShowUnityWindow = NO;

}


- (IBAction)showUnityTouched:(id)sender {
    self.isShowUnityWindow = !self.isShowUnityWindow;
    AppDelegate *appDelegate = (AppDelegate *) [UIApplication sharedApplication].delegate;

    if (self.isShowUnityWindow) {
       [appDelegate.unityWindow setFrame:CGRectMake(40, 200, 500, 500)];
        [appDelegate.unityWindow ]

        [appDelegate showUnityWindow];

    }
    else {
        [appDelegate hideUnityWindow];
    }
}
@end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-02
    相关资源
    最近更新 更多