Giter VIP home page Giter VIP logo

ios-unity5's Introduction

How to use Unity 3D within an iOS app

This is going to appear to be complicated based on the length of this article it's really not. I try to fully show some examples here, and provide some images for those who may not know where certain things are in xcode.

This would not be possible without www.the-nerd.be, Frederik Jacques. All of the settings in the xcconfig file, the UnityProjectRefresh.sh script and the project import are directly derieved from his work. The video he made in the provided link is worth watching.

This covers Unity 5+. At the time of this writing this has been successfully used with Unity 5.5.2f1 and Swift 3.1 under Xcode 8.3.2.

This works with storyboards.

You only get ONE unity view. You CANNOT run multiple Unity Views in your application at once. You will also need a way to communicate to <-> from your unity content to your iOS app. I would recommend an event bus in both your Unity code and your iOS code. AKA one central place on both sides to emit events to and listen to events on each side.

In other words you will need 2 busses, 1 on the Unity side that you can call into to emit events from on the iOS side, and one on the iOS side that Unity can call into to emit events on.

You can read more about communication between the 2 worlds from the following links:

More about embedding

http://forum.unity3d.com/threads/unity-appcontroller-subclassing.191971/

Specifically there is a bit on commuicating here with some sample code. Note, this is not for UNITY 5, but it shows the samples in OverlayUI related making functions available to the Objective-C side of things to be called from your Unity Code.

http://forum.unity3d.com/threads/unity-appcontroller-subclassing.191971/#post-1341666

Communicating from Unity -> ObjC

http://blogs.unity3d.com/2015/07/02/il2cpp-internals-pinvoke-wrappers/

http://forum.unity3d.com/threads/unity-5-2-2f1-embed-in-ios-with-extern-dllimport-__internal-methods-fails-to-compile.364809/

Communicating from Unity <-> ObjC

http://alexanderwong.me/post/29861010648/call-objective-c-from-unity-call-unity-from

Lets get started.

From Unity

First you need to have a project in unity, and you need to build it for iOS.

Under Unity 5 the project's scripting backend is already set to il2cpp so you pretty much just have to :

  • File -> Build Settings
  • Select your scene(s)
  • Press the build button
  • Remember the folder you built the project too.

From Xcode

There is a bit more to do here, but ideally the Unity.xcconfig and the UnityProjectRefresh.sh script make this easier.

Setting expectations, the project import process here takes some time, it's not instant, Unity generates a lot of files and Xcode has to import them all. So expect to stare a beachball for a few minuts while it does it's thing.

Ok! Fire up Xcode and create a new Swift project or open an existing Swift project.

Here is what we will be doing, this will seem like a lot, but it's pretty straight forward. You will fly through these steps minus the unity project import/cleanup which is not diffiucilt, it's just time consuming given the number of files.

  • Add the Unity.xcconfig file provided in this repo
  • Adjust 1 project dependent setting
  • Add a new run script build phase
  • Import your unity project
  • Clean up your unity project
  • Add the objc folder in this repo with the new custom unity init and obj-c bridging header
  • Rename main in main.mm to anything else
  • Wrap the UnityAppController into your application delegate
  • Adjust the GetAppController function in UnityAppController.h
  • Go bananas, you did it! Add the unity view wherever you want!

Add the Unity.xcconfig file provided in this repo

Drag and drop the Unity.xcconfig file into your Xcode project. Set the project to use those settings.

Adjust 1 project dependent setting

So that does a lot for you in terms of configuration, now we need to adjust 1 setting in it. Since we don't know where you decided to export your unity project too, you need to configure that.

Open up your project's build settings and scroll all the way to bottom, you will see:

UNITY_IOS_EXPORT_PATH

Adjust that path to point to your ios unity export path

You can also adjust your

UNITY_RUNTIME_VERSION

If you are not using 5.5.2f1.

Add a new run script build phase

Now we need to ensure we copy our fresh unity project on each build, so we add a new run script build phase.

Select Build Phases from your project settings to add a new build phase.

Copy the contents of the UnityProjectRefresh.sh script into this phase.

Import your unity project

This is outlined in this www.the-nerd.be video at around 5:35 - 7:30 as well, but it's now time to import our Unity project.

Create a new group and call it Unity, the name doesn't matter it's just helpful to name things so you know what they are).

You will need to open the folder you built your Unity iOS project into. It will be the same folder you specified for the UNITY_IOS_EXPORT_PATH above.

Do 1 folder at a time, this will take a minute or more to do, there are lots of files.

We are going to drag in the following folders (You don't need to copy them):

  • /your/unity/ios/export/path/Classes
  • /your/unity/ios/export/path/Libraries

Clean up your unity project

This is all in the www.the-nerd.be video as well 7:35 - There is two location we will clean up for convenience. For both of these we ONLY WANT TO REMOVE REFERENCES DO NOT MOVE TO TRASH

We don't need the Unity/Classes/Native/*.h and we don't need Unity/Libraries/libl2cpp/.

The Unity.xcconfig we applied knows where they are for compiling purposes.

Add the objc folder in this repo

You can copy these if you want, they are tiny.

  • UnityBridge.h is the SWIFT_OBJC_BRIDGING_HEADER specified in Unity.xcconfig
  • UnityUtils.h/mm is our new custom init function.

The new custom unity init function is pulled directly our of the main.mm file in your unity project. Swift does not have the same initialization convention as an objecitve-c app, so we are going to tweak things slightly.

Rename main in main.mm to anything else

In your xcode project under Unity/Classses locate the main.mm file. Within that file locate

int main(int argc, char* argv[])

Once you find that you can go ahead and see that UnityUtils.mm, which we imported above, is effectively this function. Should Unity change this initialization you will need to update your UnityUtils.mm file to match their initialization. Note that we don't copy the UIApplicationMain part. Swift will handle that.

Anyway, we need to rename this function to anything but main:

int main_unity_default(int argc, char* argv[])

Wrap the UnityAppController into your application delegate

We are taking away control from the unity generated application delegate, we need to act as a proxy for it in our AppDelegate.

First add the following variable to your AppDelegate

var currentUnityController: UnityAppController!

Now we need to initialize and proxy through the calls to the UnityAppController.

All said and done you will be left with the following:

//
//  AppDelegate.swift
//
//  Created by Adam Venturella on 10/28/15
//
//  Updated by Martin Straub on 15/03/2017.
// Added some stuff to pause unity in order to stop consuming cpu cylces and battery life, when not being displayed. 
// Indeed, unity will still sit in memory all the time, but that seems to be a more complex thing to solve. 
// Just use `startUnity` and `stopUnity` for running/pausing unity (see also ViewController example below).
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    var currentUnityController: UnityAppController?
    var application: UIApplication?
    var isUnityRunning = false
    
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
        self.application = application
        unity_init(CommandLine.argc, CommandLine.unsafeArgv)
        currentUnityController = UnityAppController()
        currentUnityController!.application(application, didFinishLaunchingWithOptions: launchOptions)
        
        // first call to startUnity will do some init stuff, so just call it here and directly stop it again
        startUnity()
        stopUnity()
        
        return true
    }
    
    func applicationWillResignActive(_ application: UIApplication) {
        if isUnityRunning {
            currentUnityController?.applicationWillResignActive(application)
        }
    }
    
    func applicationDidEnterBackground(_ application: UIApplication) {
        if isUnityRunning {
            currentUnityController?.applicationDidEnterBackground(application)
        }
    }
    
    func applicationWillEnterForeground(_ application: UIApplication) {
        if isUnityRunning {
            currentUnityController?.applicationWillEnterForeground(application)
        }
    }
    
    func applicationDidBecomeActive(_ application: UIApplication) {
        if isUnityRunning {
            currentUnityController?.applicationDidBecomeActive(application)
        }
    }
    
    func applicationWillTerminate(_ application: UIApplication) {
        if isUnityRunning {
            currentUnityController?.applicationWillTerminate(application)
        }
    }
    
    func startUnity() {
        if !isUnityRunning {
            isUnityRunning = true
            currentUnityController!.applicationDidBecomeActive(application!)
        }
    }
    
    func stopUnity() {
        if isUnityRunning {
            currentUnityController!.applicationWillResignActive(application!)
            isUnityRunning = false
        }
    }
}

Adjust the GetAppController function in UnityAppController.h

Locate the file UnityAppController.h in the xcode group Unity/Classes/

Find the following function:

inline UnityAppController*GetAppController()
{
    return (UnityAppController*)[UIApplication sharedApplication].delegate;
}

Comment that out. You will end up with this:

//inline UnityAppController*GetAppController()
//{
//    return (UnityAppController*)[UIApplication sharedApplication].delegate;
//}

Now we need to add a new version of this function:

NS_INLINE UnityAppController* GetAppController()
{
    NSObject<UIApplicationDelegate>* delegate = [UIApplication sharedApplication].delegate;
    UnityAppController* currentUnityController = (UnityAppController *)[delegate valueForKey:@"currentUnityController"];
    return currentUnityController;
}

Go bananas, you did it! Add the unity view wherever you want!

I happen to do this in a stock, single view application, so xcode generated a ViewController.swift file for me attached to a storyboard. Here is how I hooked up my little demo:

//
//  ViewController.swift
//
//  Created by Adam Venturella on 10/28/15.
//  Updated by Martin Straub on 15/03/2017.
//

import UIKit

class ViewController: UIViewController {
    var unityView: UIView?
    
    @IBAction func startUnity(sender: AnyObject) {
        let appDelegate = UIApplication.shared.delegate as! AppDelegate
        appDelegate.startUnity()
        
        unityView = UnityGetGLView()!
        
        self.view!.addSubview(unityView!)
        unityView!.translatesAutoresizingMaskIntoConstraints = false
        
        // look, non-full screen unity content!
        let views = ["view": unityView]
        let w = NSLayoutConstraint.constraints(withVisualFormat: "|-20-[view]-20-|", options: [], metrics: nil, views: views)
        let h = NSLayoutConstraint.constraints(withVisualFormat: "V:|-75-[view]-50-|", options: [], metrics: nil, views: views)
        view.addConstraints(w + h)
    }
    
    @IBAction func stopUnity(sender: AnyObject) {
        let appDelegate = UIApplication.shared.delegate as! AppDelegate
        appDelegate.stopUnity()
        unityView!.removeFromSuperview()
    }
}

ios-unity5's People

Contributors

aelavell avatar fdiaz avatar kintz09 avatar popwarfour avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ios-unity5's Issues

Apple Mach-O Linker (ld)... Linker command failed with exit code 1

Perhaps I got quite close with Xcode 9 and Unity 2017.2.0b2, but after all the build fails due to:

"ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)"

I followed the instructions carefully - however the instructions are lacking few necessary steps:

in Unity you need to define are you building for a device or a simulator
in Xcode, you need to add the UnityBridge.h path to Objective-C Bridging Header
in appdelegate, change a line to "@objc var currentUnityController: UnityAppController?"

--
Anyhow, any advice appreciated how to proceed from here... Supposedly something to change in under Build settings/Linking?

--

The error in more detail:

Undefined symbols for architecture x86_64:
"OBJC_CLASS$_UnityAppController", referenced from:
objc-class-ref in AppDelegate.o
"_unity_init", referenced from:
__T015unity_migration11AppDelegateC11applicationSbSo13UIApplicationC_s10DictionaryVySC0F16LaunchOptionsKeyVypGSg022didFinishLaunchingWithI0tF in AppDelegate.o
"_UnityGetGLView", referenced from:
__T015unity_migration14ViewControllerC10startUnityyyXl6sender_tF in ViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

"OBJC_CLASS$_UnityAppController", referenced from:
objc-class-ref in AppDelegate.o

"_unity_init", referenced from:
__T015unity_migration11AppDelegateC11applicationSbSo13UIApplicationC_s10DictionaryVySC0F16LaunchOptionsKeyVypGSg022didFinishLaunchingWithI0tF in AppDelegate.o

"_UnityGetGLView", referenced from:
__T015unity_migration14ViewControllerC10startUnityyyXl6sender_tF in ViewController.o

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Great post, better code

Could you share the sample project code ? That would be great if you have that.

Regards,
Jerry

Hi!Can you share this guide example project code?

Hi
I use this guide step make embed unity in an swift project, But not Compilate.

Error blew:
Users/zhangyong/Developer/unity3d/ios/EmbedUnity/objc/UnityBridge.h:11:9: note: in file included from /Users/zhangyong/Developer/unity3d/ios/EmbedUnity/objc/UnityBridge.h:11:

import "UnityAppController.h"

    ^

/Users/zhangyong/Developer/unity3d/unity/ios-build/Classes/UnityAppController.h:10:42: error: no type or protocol named 'UIApplicationDelegate'
@interface UnityAppController : NSObject
^
/Users/zhangyong/Developer/unity3d/ios/EmbedUnity/objc/UnityBridge.h:11:9: note: in file included from /Users/zhangyong/Developer/unity3d/ios/EmbedUnity/objc/UnityBridge.h:11:

import "UnityAppController.h"

    ^

/Users/zhangyong/Developer/unity3d/unity/ios-build/Classes/UnityAppController.h:15:2: error: unknown type name 'UIWindow'
UIWindow* _window;
^
/Users/zhangyong/Developer/unity3d/ios/EmbedUnity/objc/UnityBridge.h:11:9: note: in file included from /Users/zhangyong/Developer/unity3d/ios/EmbedUnity/objc/UnityBridge.h:11:

import "UnityAppController.h"

Xcode's Prefix.pch config is right;

XCode 7.2 Unity3d 5.3.1f1

Can you give me some suggest?
Thanks

'UnityAppController.h' file not found

Hi! I've looked through all the similar issues relating to this, but haven't had any luck yet. I'm trying to use ARKit with Unity 7 and then integrate that with native iOS.

After adding and setting up the bridging header, I get the following header on it:

screen shot 2017-09-09 at 4 31 40 pm

screen shot 2017-09-09 at 4 31 36 pm

This is what my config looks like:
screen shot 2017-09-09 at 4 32 05 pm

Anyone have ideas on how I can debug this?

Issue with prefix header

I found the guide amazing, everything is so plainly put. I am trying to run my project also in swift 3. I fixed the issues arising earlier. I am stuck at this point at the prefix header. I keep getting the error that 'UnityInterface.h' is not found. when i search the project directory, I am able to find the file. I tried to relocate the file, cleaned my build folder, deleted derived data and yet have to find a way to make it work. Has anyone else had this issue?

Support for simulator

First of all thanks for this tutorial! I wonder if you were able to run it in the simulator. I've tried generating an XCode project from Unity using "Simulator" as the target SDK but when I compile my project I get the following errors

screen shot 2016-10-19 at 8 26 23 pm

But the project that Unity generates works fine on its own.

Swift 3 support

Swift 3 has renamed Process.argc & Process.unsafeArgv. The type that those properties are now found under is called CommandLine.

main.swift should look like:

import Foundation
import UIKit

// overriding @UIApplicationMain
// http://stackoverflow.com/a/24021180/1060314

custom_unity_init(CommandLine.argc, CommandLine.unsafeArgv)
let newUnsafeArgv = UnsafeMutableRawPointer( CommandLine.unsafeArgv ).bindMemory( to: UnsafeMutablePointer<Int8>.self, capacity: Int( CommandLine.argc ) )
UIApplicationMain( CommandLine.argc, newUnsafeArgv , NSStringFromClass( UIApplication.self ), NSStringFromClass( AppDelegate.self ) )

valueForUndefinedKey "currentUnityController": Crash

After below line its crashing:
UnityAppController* currentUnityController = (UnityAppController *)[delegate valueForKey:@"currentUnityController"];

***Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ valueForUndefinedKey:]: this class is not key value coding-compliant for the key currentUnityController.

Any help please?

Instantiate an assetbundle

Hi all. I'm trying to use this amazing "hack" (Is it a hack, or will it ever be supported?) with Vuforia. Does anybody know how I might be able to instantiate an asset from an assetbundle into a Unity Scene from a view controller.

couldn't finish integrate with vuforia, please help

I make all the step reference this repo. although i can solve some issue and error by myself, I finally get the error make me helpless. if someone have experience with integrate unity3D with vuforia into a ios swift app?

i will list the error I got

  • lots of use of undeclared identifier 'UIApplication' and failed to import bridging header '/Users/funkyLover/Desktop/ios-working-on/integrate/ios-unity/UnityBridge.h'

solution: import <Foundation/Foundation.h> and <UIKit/UIKit.h> in UnityBridge.h

  • ld: library not found for -lVuforia

solution: add $(UNITY_IOS_EXPORT_PATH)/Libraries/Plugins/iOS to Library Search Paths

and i final get the error

Undefined symbols for architecture armv7:
  "il2cpp::icalls::mscorlib::System::Char::GetDataTablePointers(unsigned char const**, unsigned char const**, double const**, unsigned short const**, unsigned short const**, unsigned short const**, unsigned short const**)", referenced from:
      _Char_GetDataTablePointers_m2324968695 in Bulk_mscorlib_1.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

i have no idea about that error, please help😭

Touch problem

In my native application I'm presenting Unity (scene with cube which can be rotated with touch) as subview of my parent view. It displays correctly. But when I'm trying to rotate cube with touch, it moves a lil bit and stops, while slide touch is still in progress. Looks like Unity view is losing touch after ~ 0.5s.
Any ideas?

File not found

For some reason I am getting this build error:
screen shot 2017-07-06 at 1 57 55 pm

This is in Bulk_Generics_4.cpp, but If I comment the line out I get the same error referring to the same file being "not found" in other files. I have checked my search paths, but there does not appear to be anything wrong with it: $(UNITY_IOS_EXPORT_PATH)/Libraries/libil2cpp/include

Code Linking Issue

Thank you for the setup,
everything compiles, however I am getting a huge amount of linker errors at the end
Any ideas?

screenshot 2016-06-23 23 44 59

Unity Project does not Update

Hello there, another problem showed up.

While developing and changing some features in the Unity Project I found out that sometimes script changed in Unity are not updated and still runs in their previous behaviour in the XCode project.

exemple : OnGUI() function was used in first iteration and then was commented but still appears.
On the contrary new UI is added with button and stuff and it appears but the correct script does not run properly.

Before anything I cleaned up my project and made sure that I copied and pasted the update script in Build Settings.
I made a new project to try and see if something was due to importation problems.

Has anyone experienced something like this ?

EDIT : Found what was wrong ! Complete stupidity from my part : a doublon script file in Unity

Multiple Linker Errors

I keep on getting

Apple Mach-O Linker Error Group

  "_OBJC_CLASS_$_UnityAppController", referenced from:

  "_UnityGetGLView", referenced from:

  "RegisterMonoModules()", referenced from:

  "_UnityInitRuntime", referenced from:

  "UnityInitTrampoline()", referenced from:

  "RegisterFeatures()", referenced from:

clang: error: linker command failed with exit code 1 (use -v to see invocation)

Where are these errors coming from?

Errors after directives.

I have done all directives but when I tired to run the project;

I have encounter this error;

<unknown>:0: error: failed to import bridging header '/Users/imacmini/Desktop/Unity/Xcode Project/ProjectRemake/ProjectRemake/UnityBridge.h'

screen shot 2015-11-11 at 10 57 54

to solve this I tired this solutions on this question,

http://stackoverflow.com/questions/24146677/swift-bridging-header-import-issue

but no luck.

however closest thing i have manage to achieve is importing UIKit framework to UnityBridge.h and getting new error set like this,

screen shot 2015-11-11 at 11 01 59

screen shot 2015-11-11 at 11 02 16

any ideas ?

Problem with il2cpp

Hello,
I followed all the steps and when build the project this compile with this Linker Error.
captura de pantalla 2017-07-19 a la s 10 47 07

I am use: unity3d 5.6.1f1 Xcode: 8.3.3 swift 3

Will work with vuforia?

Hi! Thank you to your explications, this implementation will work with an unity project with vuforia?

Thank you!

Wait for Unity to be ready

in your ViewController.swift example you have to tap a button to show Unity but, what if i want to show it immediately?

You need to wait for Unity to be ready, otherwise won't work.

update ViewController.swift with the following:

//
//  ViewController.swift
//  UnityView
//
//  Created by Raul Uranga on 8/4/16.
//  Copyright © 2016 Raul Uranga. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {        
        super.viewDidLoad();

        NSNotificationCenter.defaultCenter().addObserver(
            self,
            selector: #selector(handleUnityReady),
            name: "UnityReady",
            object: nil)
    }

    func handleUnityReady() {
        let unityView = UnityGetGLView();

        self.view.insertSubview(unityView, atIndex: 0)
        unityView.translatesAutoresizingMaskIntoConstraints = false
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}

update startUnity function inside UnityAppController.mm

- (void)startUnity:(UIApplication*)application
{
    NSAssert(_unityAppReady == NO, @"[UnityAppController startUnity:] called after Unity has been initialized");

    UnityInitApplicationGraphics();

    // we make sure that first level gets correct display list and orientation
    [[DisplayManager Instance] updateDisplayListInUnity];

    UnityLoadApplication();
    Profiler_InitProfiler();

    [self showGameUI];
    [self createDisplayLink];

    UnitySetPlayerFocus(1);

       [[NSNotificationCenter defaultCenter] postNotificationName:@"UnityReady" object:self];
}

and that's it!

@reference http://stackoverflow.com/questions/30801845/integrating-unity3d-into-ios-uitabbarcontroller-uinavigationcontroller

Can you assist me integrating unity in Xcode project (Swift 3, Unity 5.5 or 5.6)

Hello guys,

I have integrated unity in Xcode project many times successfuluy using unity 5.3 and 5.4 and xcode 7.3.1 (Swift 2.3)

But I'm having an issue integrating unity in Xcode 8.3.2 (Swift 3) using Unity 5.5 or 5.6

Errors I'm facing are the il2cpp, apple o-linker etc...

I'm looking for someone to assist me through Teamviewer.

I will pay you a good dinner 👍
Respect.

ld: library not found for -liPhone-lib

ld: library not found for -liPhone-lib
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Please help me its urgent.

Unity Version: 5.6.2f1
Xcode : 8.3.3 , swift 3.0

Undeclared Identifier : UnityParseCommandLine

Been working through the tutorial/walkthrough. Seem to keep hitting snags, the latest of which is that the UnityParseCommandLine(argc, argv); is undeclared. Anyone have any thoughts or comments to help me out?

Thanks

Can't see AR view, but it's working - HEEELP

Hey there,
I'm struggling with a strange issue, and maybe you can point me in the right direction: Following all the tutorials both here and inside the issues section, I managed to have the ar part working (I can hear the audio on a videoplayback target) but the view that should show the AR view with the camera is transparent and shows nothing.

What I'm I missing? any idea?

Thanks

Xcode 9 - 2017.2.0f2 - Crash on Unity launch

I'm attempting to blend in a Unity-Vuforia project into an existing Swift project. So far everything builds, but as soon as I run the startUnity command the initialization only gets so far before crashing.

Here is the end of the console log:

-> applicationDidBecomeActive()
GfxDevice: creating device client; threaded=1
Initializing Metal device caps: Apple A10 GPU
Initialize engine version: 2017.2.0f2 (472de62575d5)
excaliburNYC was compiled with optimization - stepping may behave oddly; variables may not be available.
(lldb)

Thread Error:

0x105c61f44 <+20>: ldrb w8, [x19, #0x109]
Thread 1: EXC_BAD_ACCESS (code=1, address=0x109)

At the top of the thread error is says il2cpp::vm::Class::Init: and I have traced it back to this function below.

UnityInitApplicationGraphics();

Any help would be appreciated. Thank you.

Doesn't run didFinishLaunchingWithOptions when starting app

Hello,

I've implemented everything mentioned in the tutorial, but if I start the app an want to open the unity view, the app crashes, because the UnityGetGLView()-Method gives null back. I checked that and I've found out, that the didFinishLaunchingWithOptions Method in the AppDelegate is not called, so the UnityAppController is not created. What could be my mistake ?

Hope somebody can help me.

How I can unload unity?

I use native vuforia and unity vuforia in one ios app. How I can unload vuforia unity to load native vuforia?

Briding Header issue

Hi,

This is exactly what I need, really amazing !!

I've been struggling with one issue I'm having those errors when trying to compil the App:

Showing Recent Issues

/Users/tibo/Documents/UNITY/XCODE/UnityView/UNityView/UNityView/ViewController.swift
:0: error: bridging header '/Users/tibo/Documents/UNITY/XCODE/UnityView/UNityView/UnityBridge.h' does not exist

/Users/tibo/Documents/UNITY/XCODE/UnityView/UNityView/UNityView/AppDelegate.swift
:0: error: bridging header '/Users/tibo/Documents/UNITY/XCODE/UnityView/UNityView/UnityBridge.h' does not exist

/Users/tibo/Documents/UNITY/XCODE/UnityView/UNityView/UNityView/main.swift
:0: error: bridging header '/Users/tibo/Documents/UNITY/XCODE/UnityView/UNityView/UnityBridge.h' does not exist

I've been following your tutorial step by step But I can't figue out where it's comign from .. .

If you have any recommendation ? It would be amazing !

Thanks for your time and help :)

link error occured in xcode 7.3.1

Undefined symbols for architecture arm64: "il2cpp::icalls::mscorlib::System::Char::GetDataTablePointers(unsigned char const**, unsigned char const**, double const**, unsigned short const**, unsigned short const**, unsigned short const**, unsigned short const**)", referenced from: _Char_GetDataTablePointers_m2324968695 in Bulk_mscorlib_1.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Unity3D version is 5.4.0f3

does anyone have resolved this issue?

Missing files

Anyone else have something like 4900 missing file warnings? It builds correctly, but I'm getting the files that were removed from Classes/Native/*.h marked as missing. Not sure if this is happening for everyone else.

Add where?

When you say "Add the objc folder in this repo" it may be worth pointing out where you need to add the files from that directory.

Unable to interact with Unity

I have been able to successfully embed the unity project into an iOS application. And i can see it render the game objects on a device just fine. However I do not seem to be able to interact with any of the gameobjects.

I have verified that if i run the Unity app as a standalone Unity app everything works just fine. But when I run the embedded version it doesnt seem to let me interact with it

These are the logs I see when I run the app. Am i missing something?

2017-02-08 16:31:37.802 native-unity-kirakira[2370:742930] -> registered mono modules 0x1012432b0
-> applicationDidFinishLaunching()
-> applicationDidBecomeActive()
2017-02-08 16:31:38.094 native-unity-kirakira[2370:742930] Starting Unity
GfxDevice: creating device client; threaded=1
Init: screen size 750x1334
Initializing Metal device caps: Apple A9 GPU
Initialize engine version: 5.5.0f3 (38b4efef76f0)
UnloadTime: 1.121708 ms
SendMessage: object EventBus not found!
SendMessage: object EventBus not found!
SendMessage: object EventBus not found!
Setting up 1 worker threads for Enlighten.
Thread -> id: 16f4a7000 -> priority: 1

Cannot Find UIApplicationDelegate

Thanks for this tutorial! I am having some trouble building my app, as I get the following error on UnityAppController.h.

Cannot find protocol declaration for 'UIApplicationDelegate'; did you mean 'CAAnimationDelegate'?

This in turns creates a series of errors like: Unknown type UIViewController.

Any ideas on how to fix this?

xcode9 and unity 2017.1

has anybody had success? I was able to get it to build what it would crash consistently on startup.

No Such File - UnityBridge.h

Running on XCode 9, I encountered an issue where the project would not build after following all the setup instructions. I got compiler errors saying the UnityBridge.h file did not exist despite it being loaded properly in the project navigator. The issue appears to be in the Unity.xcconfig file. It's location for the UnityBridge.h file requires that it be in the root of the project folder. Once I moved the file there the project built without a hitch.

Prefix.pch seems not recognized

Hi!
i've been following all the steps in your tutorial, but Xcode throws lots of errors like following:

screen shot 2016-08-10 at 10 44 28 am

it seems like Xcode is totally ignoring the Prefix.pch file.

what am i missing here??

im using
Xcode 7.3.1 (7D1014)
Unity 5.4.0f3

thanks!

How to receive messages from unity?

From swift code to unity, I can send message with UnitySendMessage functiuon.

From unity to swift, I declared a plugin function in unity and implemented it in UnityUtils.mm

but How can I call swift code from C code in .mm file?
How can I call my AppDelegate.swift function or my ViewController.swift function?

Where to place .bundle Files?

First of all thank you very much for the great tutorial. It works great. I integrated the Unity Cardboard SDK in an existing Swift app. It works great so far but after the integration the cardboard sdk can not load grafics and all other stuff from the bundle files of the sdk (CardboardSDK.bundle, GoogleKitCore.bundle, GoogleKitDialogs.bundle, GoogleKitHUD.bundle, MaterialRobotoFontLoader.bundle). Does somebody know where and how to place the files that it works?

libiphone-lib.a issue

I am getting 4 errors due to libiphone-lib.a framework. Go through the logs :

Undefined symbols for architecture arm64:
[ "_MTAudioProcessingTapGetSourceAudio", referenced from:
AVFoundationVideoPlayback::PlayerPriv::ProcessAudioTap(opaqueMTAudioProcessingTap const, long, unsigned int, AudioBufferList, long, unsigned int) in libiPhone-lib.a(AVFoundationVideoPlayback.o)
"_MTAudioProcessingTapCreate", referenced from:
-[AVFoundationMediaLoader ConfigureAudioOutput] in libiPhone-lib.a(AVFoundationVideoPlayback.o)
"_MTAudioProcessingTapGetStorage", referenced from:
-[AVFoundationMediaLoader ConfigureAudioOutput] in libiPhone-lib.a(AVFoundationVideoPlayback.o)
AVFoundationVideoPlayback::PlayerPriv::PrepareAudioTap(opaqueMTAudioProcessingTap const, long, AudioStreamBasicDescription const) in libiPhone-lib.a(AVFoundationVideoPlayback.o)
AVFoundationVideoPlayback::PlayerPriv::ProcessAudioTap(opaqueMTAudioProcessingTap const, long, unsigned int, AudioBufferList, long, unsigned int) in libiPhone-lib.a(AVFoundationVideoPlayback.o)
AVFoundationVideoPlayback::PlayerPriv::FinalizeAudioTap(opaqueMTAudioProcessingTap const*) in libiPhone-lib.a(AVFoundationVideoPlayback.o)
-[AVFoundationMediaLoader StopOutput] in libiPhone-lib.a(AVFoundationVideoPlayback.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)]

Any help would be highly appreciated !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.