@@ -11,7 +11,7 @@ script and the project import are directly derieved from his work. The video
11
11
he made in the provided link is worth watching.
12
12
13
13
This covers Unity 5+. At the time of this writing this has been
14
- successfully used with Unity ` 5.2 .2f1 ` and ` Swift 3.0 ` under ` Xcode 8.0 ` .
14
+ successfully used with Unity ` 5.5 .2f1 ` and ` Swift 3.1 ` under ` Xcode 8.3.2 ` .
15
15
16
16
This works with storyboards.
17
17
@@ -91,7 +91,6 @@ which is not diffiucilt, it's just time consuming given the number of files.
91
91
- Clean up your unity project
92
92
- Add the ` objc ` folder in this repo with the new custom unity init and obj-c bridging header
93
93
- Rename ` main ` in ` main.mm ` to anything else
94
- - Alter the application delegate and create a main.swift file.
95
94
- Wrap the UnityAppController into your application delegate
96
95
- Adjust the ` GetAppController ` function in ` UnityAppController.h `
97
96
- Go bananas, you did it! Add the unity view wherever you want!
@@ -125,7 +124,7 @@ You can also adjust your
125
124
UNITY_RUNTIME_VERSION
126
125
```
127
126
128
- If you are not using ` 5.2 .2f1 ` .
127
+ If you are not using ` 5.5 .2f1 ` .
129
128
130
129
131
130
#### Add a new ` run script ` build phase
@@ -202,47 +201,6 @@ Anyway, we need to rename this function to anything but `main`:
202
201
int main_unity_default(int argc, char* argv[])
203
202
```
204
203
205
- #### Alter the swift application delegate and create a main.swift file
206
-
207
- We have to get our initialization point done however, so we need some small additions/changes.
208
-
209
- Open your ` AppDelegate.swift ` you will see this at the top of the file:
210
-
211
- ``` swift
212
- @UIApplicationMain
213
- class AppDelegate : UIResponder , UIApplicationDelegate {
214
- ```
215
-
216
- All we are going to do is remove `@UIApplicationMain ` so we
217
- are left with the following after we are done:
218
-
219
- ```swift
220
- class AppDelegate : UIResponder , UIApplicationDelegate {
221
- ```
222
-
223
- Now we need to let xcode know where our new main is . Go ahead and create
224
- a new swift file called `main.swift `. Paste this into it:
225
-
226
- ```swift
227
- import Foundation
228
- import UIKit
229
-
230
- // overriding @UIApplicationMain
231
- // http://stackoverflow.com/a/24021180/1060314
232
-
233
- custom_unity_init (CommandLine .argc , CommandLine .unsafeArgv )
234
- let newUnsafeArgv = UnsafeMutableRawPointer ( CommandLine .unsafeArgv ).bindMemory ( to : UnsafeMutablePointer < Int8 > .self , capacity : Int ( CommandLine .argc ) )
235
- UIApplicationMain ( CommandLine .argc , newUnsafeArgv , NSStringFromClass ( UIApplication.self ), NSStringFromClass ( AppDelegate.self ) )
236
- ```
237
-
238
- Assuming your bridging header is properly registered, xcode will NOT be
239
- complaining about `custom_unity_init`. If it is , something is wrong with the
240
- bridging header registration. Go check that out.
241
-
242
- Note that if your `AppDelegate` is NOT called `AppDelegate` you will need to update
243
- the last argument above in `UIApplicationMain (< argc> , < argv> , < UIApplication> , < here> )`
244
- to be whatever yours is called.
245
-
246
204
#### Wrap the UnityAppController into your application delegate
247
205
248
206
We are taking away control from the unity generated application delegate, we
@@ -278,6 +236,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
278
236
279
237
func application (_ application : UIApplication, didFinishLaunchingWithOptions launchOptions : [UIApplicationLaunchOptionsKey : Any ]? = nil ) -> Bool {
280
238
self .application = application
239
+ unity_init (CommandLine .argc , CommandLine .unsafeArgv )
281
240
currentUnityController = UnityAppController ()
282
241
currentUnityController! .application (application, didFinishLaunchingWithOptions : launchOptions)
283
242
0 commit comments