@@ -26,28 +26,19 @@ import Foundation
2626class UnityProject {
2727
2828 private let config : Config
29- private let workingPath : String
30- private let projectName : String
31- private let unitySceneNames : [ String ]
32-
3329 private let fileManager = FileManager ( )
3430 private lazy var shell = Shell ( )
35- private let unityAppPath : String
3631
3732 init ( config: Config ) {
3833 self . config = config
39- self . projectName = config. iOS. projectName
40- self . workingPath = config. unity. projectPath
41- self . unityAppPath = config. unity. applicationPath
42- self . unitySceneNames = config. unity. sceneNames
4334 }
4435
4536 func create( ) -> Result {
46- guard UBKit . validatePath ( unityAppPath , isDirectory: false ) else {
47- return . failure( UBKitError . invalidFolder ( unityAppPath ) )
37+ guard UBKit . validatePath ( config . unity . applicationPath , isDirectory: false ) else {
38+ return . failure( UBKitError . invalidFolder ( config . unity . applicationPath ) )
4839 }
4940
50- print ( " Unity Project Path: \( workingPath ) \n " )
41+ print ( " Unity Project Path: \( config . unity . projectPath ) \n " )
5142 let unityFolderResult = createUnityFolder ( )
5243 guard unityFolderResult == . success else {
5344 return unityFolderResult
@@ -83,7 +74,7 @@ private extension UnityProject {
8374 func createUnityFolder( ) -> Result {
8475 do {
8576 try fileManager. createDirectory (
86- atPath: workingPath ,
77+ atPath: config . unity . projectPath ,
8778 withIntermediateDirectories: false ,
8879 attributes: nil )
8980 } catch {
@@ -95,11 +86,11 @@ private extension UnityProject {
9586
9687 func generateUnityProject( ) -> Result {
9788 let semaphore = DispatchSemaphore ( value: 0 )
98- let unityProjectPath = workingPath . appending ( projectName)
89+ let unityProjectPath = config . unity . projectPath . appending ( config . unity . projectName)
9990 var statusCode : Int32 = 0
10091
10192 shell. perform (
102- unityAppPath ,
93+ config . unity . applicationPath ,
10394 UnityCommandLine . Arguments. batchmode,
10495 UnityCommandLine . Arguments. createProject,
10596 unityProjectPath,
@@ -123,7 +114,7 @@ private extension UnityProject {
123114 }
124115
125116 func createUnityEditorScripts( ) -> Result {
126- let assetsFilePath = workingPath . appending ( projectName) . appending ( " /Assets/ " )
117+ let assetsFilePath = config . unity . projectPath . appending ( config . unity . projectName) . appending ( " /Assets/ " )
127118 guard UBKit . validatePath ( assetsFilePath, isDirectory: true ) else {
128119 return . failure( UBKitError . invalidFolder ( assetsFilePath) )
129120 }
@@ -139,21 +130,21 @@ private extension UnityProject {
139130
140131 guard fileManager. createFile (
141132 atPath: editorFilePath. appending ( " iOSBuildScript.cs " ) ,
142- contents: File . unityBuildScriptFile ( iOSProjectFolderPath: config. iOS. projectPath, iOSProjectName: projectName) ,
133+ contents: File . unityBuildScriptFile ( iOSProjectFolderPath: config. iOS. projectPath, iOSProjectName: config . iOS . projectName) ,
143134 attributes: nil ) else {
144135 return . failure( UBKitError . unableToCreateFile ( " Unity iOS Build Script " ) )
145136 }
146137
147138 guard fileManager. createFile (
148139 atPath: editorFilePath. appending ( " XcodeProjectRefresher.cs " ) ,
149- contents: File . unityProjectScriptFile ( projectName : projectName, iOSProjectPath: config. iOS. projectPath) ,
140+ contents: File . unityProjectScriptFile ( iOSProjectName : config . iOS . projectName, iOSProjectPath: config. iOS. projectPath) ,
150141 attributes: nil ) else {
151142 return . failure( UBKitError . unableToCreateFile ( " Unity Project Script " ) )
152143 }
153144
154145 guard fileManager. createFile (
155146 atPath: editorFilePath. appending ( " XcodeFrameworks.cs " ) ,
156- contents: File . unityFrameworksScriptFile ( projectName : projectName, iOSProjectPath: config. iOS. projectPath) ,
147+ contents: File . unityFrameworksScriptFile ( iOSProjectName : config . iOS . projectName, iOSProjectPath: config. iOS. projectPath) ,
157148 attributes: nil ) else {
158149 return . failure( UBKitError . unableToCreateFile ( " Xcode Frameworks Script " ) )
159150 }
@@ -164,21 +155,21 @@ private extension UnityProject {
164155 func runInitialProjectBuild( ) -> Result {
165156 let semaphore = DispatchSemaphore ( value: 0 )
166157 var statusCode : Int32 = 999
167- let projectPath = workingPath . appending ( projectName)
158+ let projectPath = config . unity . projectPath . appending ( config . unity . projectName)
168159 let outputLocation = projectPath. appending ( " / " ) . appending ( " ios_build " )
169160
170161 // MARK: - Main
171- print ( " Initializing Unity scene \( unitySceneNames [ 0 ] ) for iOS... " )
162+ print ( " Initializing Unity scene \( config . unity . sceneNames [ 0 ] ) for iOS... " )
172163 print ( " This will take some time to complete \n " )
173164 shell. perform (
174- unityAppPath ,
165+ config . unity . applicationPath ,
175166 UnityCommandLine . Arguments. batchmode,
176167 UnityCommandLine . Arguments. projectPath,
177168 projectPath,
178169 UnityCommandLine . Arguments. outputLocation,
179170 outputLocation,
180171 UnityCommandLine . Arguments. sceneName,
181- unitySceneNames [ 0 ] ,
172+ config . unity . sceneNames [ 0 ] ,
182173 UnityCommandLine . Arguments. executeMethod,
183174 UnityCommandLine . buildAction,
184175 UnityCommandLine . Arguments. quit,
0 commit comments