@@ -196,11 +196,18 @@ private static void OnEditorUpdate()
196196                        // If this is one of the development Apple plug-in Unity projects, it needs to be handled as a special case because  
197197                        //  it isn't loaded/managed by the package manager; all of the assets are local under Assets/ 
198198                        // 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 ) 
200200                        { 
201-                             if  ( buildStepEntry . Value . SupportedTargets . Length   >   0   &&   ! _appleUnityPackages . ContainsKey ( buildStepEntry . Value . DisplayName ) ) 
201+                             if  ( ! _appleUnityPackages . ContainsKey ( buildStep . DisplayName ) ) 
202202                            { 
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+                                 } 
204211                            } 
205212                        } 
206213
@@ -244,42 +251,30 @@ private static void ValidateLibraries()
244251        { 
245252            foreach  ( var  applePackage  in  _appleUnityPackages . Values ) 
246253            { 
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 ) 
250256                { 
251-                     if  ( buildStep . DisplayName   ==   applePackage . DisplayName ) 
257+                     if  ( Array . IndexOf ( buildStep . SupportedTargets ,   GetUnityBuildTarget ( _trackedApplePlatform ) )   >   - 1 ) 
252258                    { 
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 ) 
256261                        { 
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 ) ; 
259268                        } 
260269                    } 
261-                 } 
262- 
263-                 if  ( isCurrentPlatformSupported ) 
264-                 { 
265-                     AppleNativeLibrary  currLibrary  =  GetLibrary ( applePackage . DisplayName ,  _trackedAppleConfig . Principal ,  _trackedApplePlatform ) ; 
266-                     if  ( ! currLibrary . IsValid ) 
270+                     else  if  ( buildStep . IsEnabled ) 
267271                    { 
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."; 
272274
273275                        Debug . LogWarning ( warningMessage ) ; 
274276                    } 
275277                } 
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-                 } 
283278            } 
284279        } 
285280
@@ -391,10 +386,16 @@ public static AppleNativeLibrary GetLibrary(string packageDisplayName, string ap
391386        /// <param name="packageCollection">An iterable collection of PackageInfo structs</param> 
392387        private  static   void  AddPackagesFromCollection ( IEnumerable < UnityEditor . PackageManager . PackageInfo >  packageCollection ,  bool  logPackagesAfterUpdate  =  true ) 
393388        { 
389+             // Ensure collection of build steps is current; package names will be validated against build step names. 
390+             _defaultProfile . ResolveBuildSteps ( ) ; 
391+ 
394392            bool  packagesAdded  =  false ; 
395393            foreach  ( var  unityPackage  in  packageCollection ) 
396394            { 
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 ) ) 
398399                { 
399400                    AppleUnityPackage  applePackage  =  new  AppleUnityPackage ( unityPackage . name ,  unityPackage . displayName ,  unityPackage . resolvedPath ) ; 
400401                    if  ( ! applePackage . PlayModeSupportLibrary . IsValid ) 
@@ -407,6 +408,14 @@ private static void AddPackagesFromCollection(IEnumerable<UnityEditor.PackageMan
407408                    _appleUnityPackages [ applePackage . DisplayName ]  =  applePackage ; 
408409                    packagesAdded  =  true ; 
409410                } 
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+ 
410419            } 
411420
412421            if  ( packagesAdded  &&  logPackagesAfterUpdate ) 
@@ -471,35 +480,42 @@ private static void SyncronizePlayModeSupportLibraries()
471480        /// </summary> 
472481        private  static   void  LogLibrarySummary ( ) 
473482        { 
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 " ; 
475484            bool  librariesFound  =  false ; 
476485            foreach  ( AppleUnityPackage  package  in  _appleUnityPackages . Values ) 
477486            { 
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 ) 
481488                { 
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 ) 
484492                    { 
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 ; 
486499                    } 
487-                     librariesFound  =  true ; 
488-                 } 
489500
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 ) 
495503                    { 
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 ) 
498506                        { 
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+                             } 
500512                        } 
513+                         librariesFound  =  true ; 
501514                    } 
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 "; 
503519                } 
504520            } 
505521
0 commit comments