@@ -196,11 +196,18 @@ private static void OnEditorUpdate()
196
196
// If this is one of the development Apple plug-in Unity projects, it needs to be handled as a special case because
197
197
// it isn't loaded/managed by the package manager; all of the assets are local under Assets/
198
198
// All Apple plug-ins will have an AppleBuildStep implementation, so check for build steps that haven't been added already
199
- foreach ( var buildStepEntry in _defaultProfile . buildSteps )
199
+ foreach ( var buildStep in _defaultProfile . buildSteps . Values )
200
200
{
201
- if ( buildStepEntry . Value . SupportedTargets . Length > 0 && ! _appleUnityPackages . ContainsKey ( buildStepEntry . Value . DisplayName ) )
201
+ if ( ! _appleUnityPackages . ContainsKey ( buildStep . DisplayName ) )
202
202
{
203
- _appleUnityPackages [ buildStepEntry . Value . DisplayName ] = new AppleUnityPackage ( "Local Project" , buildStepEntry . Value . DisplayName , Application . dataPath ) ;
203
+ if ( buildStep . IsNativePlugIn )
204
+ {
205
+ _appleUnityPackages [ buildStep . DisplayName ] = new AppleUnityPackage ( "Local Project" , buildStep . DisplayName , Application . dataPath ) ;
206
+ }
207
+ else
208
+ {
209
+ _appleUnityPackages [ buildStep . DisplayName ] = new AppleUnityPackage ( "Local Project" , buildStep . DisplayName ) ;
210
+ }
204
211
}
205
212
}
206
213
@@ -244,42 +251,30 @@ private static void ValidateLibraries()
244
251
{
245
252
foreach ( var applePackage in _appleUnityPackages . Values )
246
253
{
247
- bool isCurrentPlatformSupported = false ;
248
- bool isBuildStepEnabled = false ;
249
- foreach ( var buildStep in _defaultProfile . buildSteps . Values )
254
+ AppleBuildStep buildStep = _defaultProfile . FindBuildStep ( applePackage . DisplayName ) ;
255
+ if ( buildStep != null && buildStep . IsNativePlugIn )
250
256
{
251
- if ( buildStep . DisplayName == applePackage . DisplayName )
257
+ if ( Array . IndexOf ( buildStep . SupportedTargets , GetUnityBuildTarget ( _trackedApplePlatform ) ) > - 1 )
252
258
{
253
- isBuildStepEnabled = buildStep . IsEnabled ;
254
- BuildTarget unityBuildTarget = GetUnityBuildTarget ( _trackedApplePlatform ) ;
255
- if ( Array . IndexOf ( buildStep . SupportedTargets , unityBuildTarget ) > - 1 )
259
+ AppleNativeLibrary currLibrary = GetLibrary ( applePackage . DisplayName , _trackedAppleConfig . Principal , _trackedApplePlatform ) ;
260
+ if ( ! currLibrary . IsValid )
256
261
{
257
- isCurrentPlatformSupported = true ;
258
- break ;
262
+ string warningMessage = $ "[Apple Unity Plug-Ins] Missing { _trackedAppleConfig . Principal } { applePackage . DisplayName } native library for { _trackedApplePlatform } \n "
263
+ + $ " { _trackedAppleConfig . Fallback } { applePackage . DisplayName } native library for { _trackedApplePlatform } will be used as a fallback.\n "
264
+ + $ " To generate the { _trackedAppleConfig . Principal } native library for { applePackage . DisplayName } , try re-building the { applePackage . DisplayName } plug-in with the following command line (assuming the working directory is the Apple Unity Plug-In project root folder):\n \n "
265
+ + $ " <b><color=orange>$> python3 ./build.py -p { applePackage . ShortName } </color></b>\n ";
266
+
267
+ Debug . LogWarning ( warningMessage ) ;
259
268
}
260
269
}
261
- }
262
-
263
- if ( isCurrentPlatformSupported )
264
- {
265
- AppleNativeLibrary currLibrary = GetLibrary ( applePackage . DisplayName , _trackedAppleConfig . Principal , _trackedApplePlatform ) ;
266
- if ( ! currLibrary . IsValid )
270
+ else if ( buildStep . IsEnabled )
267
271
{
268
- string warningMessage = $ "[Apple Unity Plug-Ins] Missing { _trackedAppleConfig . Principal } { applePackage . DisplayName } native library for { _trackedApplePlatform } \n "
269
- + $ " { _trackedAppleConfig . Fallback } { applePackage . DisplayName } native library for { _trackedApplePlatform } will be used as a fallback.\n "
270
- + $ " To generate the { _trackedAppleConfig . Principal } native library for { applePackage . DisplayName } , try re-building the { applePackage . DisplayName } plug-in with the following command line (assuming the working directory is the Apple Unity Plug-In project root folder):\n \n "
271
- + $ " <b><color=orange>$> python3 ./build.py -p { applePackage . ShortName } </color></b>\n ";
272
+ string warningMessage = $ "[Apple Unity Plug-Ins] Targeting unsupported platform '{ _trackedApplePlatform } ' for Apple plug-in package { applePackage . DisplayName } .\n "
273
+ + $ " To continue building for the current platform, please disable { applePackage . DisplayName } in the Apple Build Settings window.";
272
274
273
275
Debug . LogWarning ( warningMessage ) ;
274
276
}
275
277
}
276
- else if ( isBuildStepEnabled )
277
- {
278
- string warningMessage = $ "[Apple Unity Plug-Ins] Targeting unsupported platform '{ _trackedApplePlatform } ' for Apple plug-in package { applePackage . DisplayName } .\n "
279
- + $ " To continue building for the current platform, please disable { applePackage . DisplayName } in the Apple Build Settings window.";
280
-
281
- Debug . LogWarning ( warningMessage ) ;
282
- }
283
278
}
284
279
}
285
280
@@ -391,10 +386,16 @@ public static AppleNativeLibrary GetLibrary(string packageDisplayName, string ap
391
386
/// <param name="packageCollection">An iterable collection of PackageInfo structs</param>
392
387
private static void AddPackagesFromCollection ( IEnumerable < UnityEditor . PackageManager . PackageInfo > packageCollection , bool logPackagesAfterUpdate = true )
393
388
{
389
+ // Ensure collection of build steps is current; package names will be validated against build step names.
390
+ _defaultProfile . ResolveBuildSteps ( ) ;
391
+
394
392
bool packagesAdded = false ;
395
393
foreach ( var unityPackage in packageCollection )
396
394
{
397
- if ( unityPackage . name . StartsWith ( AppleUnityPackageNamePrefix ) && unityPackage . author . name == AppleUnityPackageAuthorName && ! _appleUnityPackages . ContainsKey ( unityPackage . displayName ) )
395
+ AppleBuildStep buildStep = _defaultProfile . FindBuildStep ( unityPackage . displayName ) ;
396
+
397
+ // Apple packages with native libraries will always have a build step defined for handling those libraries, so validate here.
398
+ if ( buildStep != null && buildStep . IsNativePlugIn && buildStep . DisplayName == unityPackage . displayName && unityPackage . author . name == AppleUnityPackageAuthorName && ! _appleUnityPackages . ContainsKey ( unityPackage . displayName ) )
398
399
{
399
400
AppleUnityPackage applePackage = new AppleUnityPackage ( unityPackage . name , unityPackage . displayName , unityPackage . resolvedPath ) ;
400
401
if ( ! applePackage . PlayModeSupportLibrary . IsValid )
@@ -407,6 +408,14 @@ private static void AddPackagesFromCollection(IEnumerable<UnityEditor.PackageMan
407
408
_appleUnityPackages [ applePackage . DisplayName ] = applePackage ;
408
409
packagesAdded = true ;
409
410
}
411
+ // If there's no build step or the build step isn't associated with a native plug-in track the library-free (C# only) package.
412
+ else if ( unityPackage . name . StartsWith ( AppleUnityPackageNamePrefix ) && unityPackage . author . name == AppleUnityPackageAuthorName && ! _appleUnityPackages . ContainsKey ( unityPackage . displayName ) )
413
+ {
414
+ AppleUnityPackage applePackage = new AppleUnityPackage ( unityPackage . name , unityPackage . displayName ) ;
415
+ _appleUnityPackages [ applePackage . DisplayName ] = applePackage ;
416
+ packagesAdded = true ;
417
+ }
418
+
410
419
}
411
420
412
421
if ( packagesAdded && logPackagesAfterUpdate )
@@ -471,35 +480,42 @@ private static void SyncronizePlayModeSupportLibraries()
471
480
/// </summary>
472
481
private static void LogLibrarySummary ( )
473
482
{
474
- string summary = "[Apple Unity Plug-ins] Apple native plug-ins updated.\n Tracking the following plug-in packages and native libraries:\n \n " ;
483
+ string summary = "[Apple Unity Plug-ins] Apple native plug-ins updated.\n Tracking the following plug-in packages and native libraries:\n " ;
475
484
bool librariesFound = false ;
476
485
foreach ( AppleUnityPackage package in _appleUnityPackages . Values )
477
486
{
478
- summary += $ "\n <b>{ package . DisplayName } </b> [{ package . Name } ]:\n Package Source Path: { package . SourcePath } \n ";
479
- var debugLibraries = package . GetLibraries ( AppleConfigID . Debug ) ;
480
- if ( debugLibraries . Length > 0 )
487
+ if ( package . IsNativePackage )
481
488
{
482
- summary += " Debug Libraries (file name - platform):\n " ;
483
- foreach ( var debugLibrary in debugLibraries )
489
+ summary += $ "\n <b>{ package . DisplayName } </b> [{ package . Name } ]:\n Package Source Path: { package . SourcePath } \n ";
490
+ var debugLibraries = package . GetLibraries ( AppleConfigID . Debug ) ;
491
+ if ( debugLibraries . Length > 0 )
484
492
{
485
- summary += $ " { debugLibrary . FileName } - { debugLibrary . Platform } \n ";
493
+ summary += " Debug Libraries (file name - platform):\n " ;
494
+ foreach ( var debugLibrary in debugLibraries )
495
+ {
496
+ summary += $ " { debugLibrary . FileName } - { debugLibrary . Platform } \n ";
497
+ }
498
+ librariesFound = true ;
486
499
}
487
- librariesFound = true ;
488
- }
489
500
490
- var releaseLibraries = package . GetLibraries ( AppleConfigID . Release ) ;
491
- if ( releaseLibraries . Length > 0 )
492
- {
493
- summary += " Release Libraries (file name - platform):\n " ;
494
- foreach ( var releaseLibrary in releaseLibraries )
501
+ var releaseLibraries = package . GetLibraries ( AppleConfigID . Release ) ;
502
+ if ( releaseLibraries . Length > 0 )
495
503
{
496
- summary += $ " { releaseLibrary . FileName } - { releaseLibrary . Platform } \n ";
497
- if ( releaseLibrary . DebugSymbolsFileName != string . Empty )
504
+ summary += " Release Libraries (file name - platform): \n " ;
505
+ foreach ( var releaseLibrary in releaseLibraries )
498
506
{
499
- summary += $ " { releaseLibrary . DebugSymbolsFileName } - { releaseLibrary . Platform } \n ";
507
+ summary += $ " { releaseLibrary . FileName } - { releaseLibrary . Platform } \n ";
508
+ if ( releaseLibrary . DebugSymbolsFileName != string . Empty )
509
+ {
510
+ summary += $ " { releaseLibrary . DebugSymbolsFileName } - { releaseLibrary . Platform } \n ";
511
+ }
500
512
}
513
+ librariesFound = true ;
501
514
}
502
- librariesFound = true ;
515
+ }
516
+ else
517
+ {
518
+ summary += $ "\n <b>{ package . DisplayName } </b> [{ package . Name } ]:\n Non-native (C# Script or asset only) plug-in/extension.\n <b>No libraries to list.</b>\n ";
503
519
}
504
520
}
505
521
0 commit comments