@@ -24,6 +24,10 @@ namespace GooglePlayGames.Editor
2424 using UnityEditor ;
2525 using UnityEngine ;
2626
27+ #if UNITY_2021_2_OR_NEWER
28+ using UnityEditor . Build ;
29+ #endif
30+
2731 /// <summary>
2832 /// Google Play Game Services Setup dialog for Android.
2933 /// </summary>
@@ -57,15 +61,14 @@ public class GPGSAndroidSetupUI : EditorWindow
5761 /// <summary>
5862 /// Menus the item for GPGS android setup.
5963 /// </summary>
60- [ MenuItem ( "Window/ Google Play Games/Setup/Android setup..." , false , 1 ) ]
64+ [ MenuItem ( "Google/ Play Games/Setup/Android setup..." , false , 1 ) ]
6165 public static void MenuItemFileGPGSAndroidSetup ( )
6266 {
63- EditorWindow window = EditorWindow . GetWindow (
64- typeof ( GPGSAndroidSetupUI ) , true , GPGSStrings . AndroidSetup . Title ) ;
67+ var window = EditorWindow . GetWindow < GPGSAndroidSetupUI > ( true , GPGSStrings . AndroidSetup . Title ) ;
6568 window . minSize = new Vector2 ( 500 , 400 ) ;
6669 }
6770
68- [ MenuItem ( "Window/ Google Play Games/Setup/Android setup..." , true ) ]
71+ [ MenuItem ( "Google/ Play Games/Setup/Android setup..." , true ) ]
6972 public static bool EnableAndroidMenuItem ( )
7073 {
7174#if UNITY_ANDROID
@@ -111,8 +114,6 @@ public static bool PerformSetup(
111114 // check the bundle id and set it if needed.
112115 CheckBundleId ( ) ;
113116
114- GPGSUtil . CheckAndFixDependencies ( ) ;
115- GPGSUtil . CheckAndFixVersionedAssestsPaths ( ) ;
116117 AssetDatabase . Refresh ( ) ;
117118
118119 Google . VersionHandler . VerboseLoggingEnabled = true ;
@@ -162,26 +163,26 @@ public static bool PerformSetup(string webClientId, string appId, string nearbyS
162163 }
163164 }
164165
165- // check for valid app id
166- if ( ! GPGSUtil . LooksLikeValidAppId ( appId ) && string . IsNullOrEmpty ( nearbySvcId ) )
167- {
168- GPGSUtil . Alert ( GPGSStrings . Setup . AppIdError ) ;
169- return false ;
170- }
171-
172- if ( nearbySvcId != null )
166+ if ( string . IsNullOrEmpty ( nearbySvcId ) )
173167 {
174- #if UNITY_ANDROID
175- if ( ! NearbyConnectionUI . PerformSetup ( nearbySvcId , true ) )
168+ // check for valid app id
169+ if ( ! GPGSUtil . LooksLikeValidAppId ( appId ) )
176170 {
171+ GPGSUtil . Alert ( GPGSStrings . Setup . AppIdError ) ;
177172 return false ;
178173 }
179- #endif
180174 }
175+ #if UNITY_ANDROID
176+ else if ( ! NearbyConnectionUI . PerformSetup ( nearbySvcId , true ) )
177+ {
178+ return false ;
179+ }
180+ #endif
181181
182182 GPGSProjectSettings . Instance . Set ( GPGSUtil . APPIDKEY , appId ) ;
183183 GPGSProjectSettings . Instance . Set ( GPGSUtil . WEBCLIENTIDKEY , webClientId ) ;
184184 GPGSProjectSettings . Instance . Save ( ) ;
185+ GPGSUtil . PatchAndroidManifest ( ) ;
185186 GPGSUtil . UpdateGameInfo ( ) ;
186187
187188 // check that Android SDK is there
@@ -196,7 +197,7 @@ public static bool PerformSetup(string webClientId, string appId, string nearbyS
196197 }
197198
198199 // Generate AndroidManifest.xml
199- GPGSUtil . GenerateAndroidManifest ( ) ;
200+ GPGSUtil . UpdateGameInfo ( ) ;
200201
201202 // refresh assets, and we're done
202203 AssetDatabase . Refresh ( ) ;
@@ -298,9 +299,8 @@ public void OnGUI()
298299 }
299300 catch ( Exception e )
300301 {
301- GPGSUtil . Alert (
302- GPGSStrings . Error ,
303- "Invalid classname: " + e . Message ) ;
302+ GPGSUtil . Alert ( GPGSStrings . Error , "Invalid classname: " + e . Message ) ;
303+ Debug . LogException ( e ) ;
304304 }
305305 }
306306
@@ -355,48 +355,45 @@ public static void CheckBundleId()
355355 string packageName = GPGSProjectSettings . Instance . Get (
356356 GPGSUtil . ANDROIDBUNDLEIDKEY , string . Empty ) ;
357357 string currentId ;
358- #if UNITY_5_6_OR_NEWER
359- currentId = PlayerSettings . GetApplicationIdentifier (
360- BuildTargetGroup . Android ) ;
358+ #if UNITY_2021_2_OR_NEWER
359+ currentId = PlayerSettings . GetApplicationIdentifier ( NamedBuildTarget . Android ) ;
360+ #elif UNITY_5_6_OR_NEWER
361+ currentId = PlayerSettings . GetApplicationIdentifier ( BuildTargetGroup . Android ) ;
361362#else
362363 currentId = PlayerSettings . bundleIdentifier ;
363364#endif
364- if ( ! string . IsNullOrEmpty ( packageName ) )
365+ if ( string . IsNullOrEmpty ( packageName ) )
365366 {
366- if ( string . IsNullOrEmpty ( currentId ) ||
367- currentId == "com.Company.ProductName" )
368- {
369- #if UNITY_5_6_OR_NEWER
370- PlayerSettings . SetApplicationIdentifier (
371- BuildTargetGroup . Android , packageName ) ;
367+ Debug . Log ( "NULL package!!" ) ;
368+ }
369+ else if ( string . IsNullOrEmpty ( currentId ) || currentId == "com.Company.ProductName" )
370+ {
371+ #if UNITY_2021_2_OR_NEWER
372+ PlayerSettings . SetApplicationIdentifier ( NamedBuildTarget . Android , packageName ) ;
373+ #elif UNITY_5_6_OR_NEWER
374+ PlayerSettings . SetApplicationIdentifier ( BuildTargetGroup . Android , packageName ) ;
372375#else
373- PlayerSettings . bundleIdentifier = packageName ;
376+ PlayerSettings . bundleIdentifier = packageName ;
374377#endif
375- }
376- else if ( currentId != packageName )
378+ }
379+ else if ( currentId != packageName )
380+ {
381+ if ( EditorUtility . DisplayDialog (
382+ "Set Bundle Identifier?" ,
383+ "The server configuration is using " + packageName +
384+ ", but the player settings is set to " + currentId +
385+ ".\n Set the Bundle Identifier to " + packageName + "?" ,
386+ "OK" , "Cancel" ) )
377387 {
378- if ( EditorUtility . DisplayDialog (
379- "Set Bundle Identifier?" ,
380- "The server configuration is using " +
381- packageName + ", but the player settings is set to " +
382- currentId + ".\n Set the Bundle Identifier to " +
383- packageName + "?" ,
384- "OK" ,
385- "Cancel" ) )
386- {
387- #if UNITY_5_6_OR_NEWER
388- PlayerSettings . SetApplicationIdentifier (
389- BuildTargetGroup . Android , packageName ) ;
388+ #if UNITY_2021_2_OR_NEWER
389+ PlayerSettings . SetApplicationIdentifier ( NamedBuildTarget . Android , packageName ) ;
390+ #elif UNITY_5_6_OR_NEWER
391+ PlayerSettings . SetApplicationIdentifier ( BuildTargetGroup . Android , packageName ) ;
390392#else
391- PlayerSettings . bundleIdentifier = packageName ;
393+ PlayerSettings . bundleIdentifier = packageName ;
392394#endif
393- }
394395 }
395396 }
396- else
397- {
398- Debug . Log ( "NULL package!!" ) ;
399- }
400397 }
401398
402399 /// <summary>
0 commit comments