File tree Expand file tree Collapse file tree 2 files changed +43
-2
lines changed
com.onesignal.unity.android/Editor Expand file tree Collapse file tree 2 files changed +43
-2
lines changed Original file line number Diff line number Diff line change 1+ using System . IO ;
2+ using UnityEditor ;
3+
4+ namespace OneSignalSDK {
5+
6+ [ InitializeOnLoad ]
7+ sealed class MigrateAndroidResources {
8+ static MigrateAndroidResources ( ) {
9+ UpdateBuildDotGradleContains ( ) ;
10+ }
11+
12+ /// <summary>
13+ /// Updates Assets/Plugins/Android/OneSignalConfig.androidlib/build.gradle
14+ /// with contains provided by OneSignal-Unity-SDK 5.1.13.
15+ /// Includes compatibility with Unity 6, as it's Gradle version has new
16+ /// requirements.
17+ /// </summary>
18+ private static void UpdateBuildDotGradleContains ( ) {
19+ if ( ! Directory . Exists ( ExportAndroidResourcesStep . _pluginExportPath ) )
20+ return ;
21+
22+ string exportedFilename = Path . Combine (
23+ ExportAndroidResourcesStep . _pluginExportPath ,
24+ "build.gradle"
25+ ) ;
26+ string exportedContains = File . ReadAllText ( exportedFilename ) ;
27+
28+ string packageFilename = Path . Combine (
29+ ExportAndroidResourcesStep . _pluginPackagePath ,
30+ "build.gradle"
31+ ) ;
32+ string packageContains = File . ReadAllText ( packageFilename ) ;
33+
34+ // We want to copy only when needed, otherwise it can reset file
35+ // properties, such as permissions and timestamps
36+ if ( exportedContains != packageContains ) {
37+ File . Copy ( packageFilename , exportedFilename , true ) ;
38+ }
39+ }
40+ }
41+ }
Original file line number Diff line number Diff line change @@ -131,8 +131,8 @@ private void MigratePluginToAndroidlib() {
131131 private static readonly string _packagePath = Path . Combine ( "Packages" , "com.onesignal.unity.android" , "Editor" ) ;
132132 private static readonly string _androidPluginsPath = Path . Combine ( "Assets" , "Plugins" , "Android" ) ;
133133
134- private static readonly string _pluginPackagePath = Path . Combine ( _packagePath , _pluginName ) ;
135- private static readonly string _pluginExportPath = Path . Combine ( _androidPluginsPath , _pluginName ) ;
134+ internal static readonly string _pluginPackagePath = Path . Combine ( _packagePath , _pluginName ) ;
135+ internal static readonly string _pluginExportPath = Path . Combine ( _androidPluginsPath , _pluginName ) ;
136136
137137 private static readonly string _manifestPackagePath = Path . Combine ( _pluginPackagePath , "AndroidManifest.xml" ) ;
138138 private static readonly string _manifestExportPath = Path . Combine ( _pluginExportPath , "AndroidManifest.xml" ) ;
You can’t perform that action at this time.
0 commit comments