From 9f6c33c38acd60b86cd374dd3afd36fef8749063 Mon Sep 17 00:00:00 2001 From: Shepherd Date: Tue, 3 Oct 2023 19:30:06 -0400 Subject: [PATCH] Move icons and .wav file to /src/main --- .../SetupSteps/ExportAndroidResourcesStep.cs | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/com.onesignal.unity.android/Editor/SetupSteps/ExportAndroidResourcesStep.cs b/com.onesignal.unity.android/Editor/SetupSteps/ExportAndroidResourcesStep.cs index bee504527..0a2baf1b2 100644 --- a/com.onesignal.unity.android/Editor/SetupSteps/ExportAndroidResourcesStep.cs +++ b/com.onesignal.unity.android/Editor/SetupSteps/ExportAndroidResourcesStep.cs @@ -96,13 +96,29 @@ protected override void _runStep() { private void migratePluginToAndroidlib() { if (Directory.Exists(_pluginV3ExportPath)) { if (!Directory.Exists(_pluginExportPath)) { - // Remove project.properties - if (File.Exists(_projectPropertiesV3ExportPath)) { - AssetDatabase.DeleteAsset(_projectPropertiesV3ExportPath); + try + { + AssetDatabase.StartAssetEditing(); + + // Remove project.properties + if (File.Exists(_projectPropertiesV3ExportPath)) { + AssetDatabase.DeleteAsset(_projectPropertiesV3ExportPath); + } + + // Rename OneSignalConfig.plugin to OneSignalConfig.androidlib + AssetDatabase.MoveAsset(_pluginV3ExportPath, _pluginExportPath); } + finally + { + AssetDatabase.StopAssetEditing(); + } + + // Move the icons and .wav file to /src/main + if (Directory.Exists(_resV3ExportPath)) { + Directory.CreateDirectory(Path.GetDirectoryName(_resExportPath)); - // Rename OneSignalConfig.plugin to OneSignalConfig.androidlib - AssetDatabase.MoveAsset(_pluginV3ExportPath, _pluginExportPath); + FileUtil.MoveFileOrDirectory(_resV3ExportPath, _resExportPath); + } } else { AssetDatabase.DeleteAsset(_pluginV3ExportPath); } @@ -119,9 +135,14 @@ private void migratePluginToAndroidlib() { private static readonly string _manifestPackagePath = Path.Combine(_pluginPackagePath, "AndroidManifest.xml"); private static readonly string _manifestExportPath = Path.Combine(_pluginExportPath, "AndroidManifest.xml"); + private const string _resPath = "src/main/res"; + private static readonly string _resExportPath = Path.Combine(_pluginExportPath, _resPath); + // Old OneSignalConfig name used from 3.x.x to 5.0.2 - private const string _pluginNamev3 = "OneSignalConfig.plugin"; - private static readonly string _pluginV3ExportPath = Path.Combine(_androidPluginsPath, _pluginNamev3); + private const string _pluginNameV3 = "OneSignalConfig.plugin"; + private static readonly string _pluginV3ExportPath = Path.Combine(_androidPluginsPath, _pluginNameV3); private static readonly string _projectPropertiesV3ExportPath = Path.Combine(_pluginV3ExportPath, "project.properties"); + private const string _resV3Path = "res"; + private static readonly string _resV3ExportPath = Path.Combine(_pluginExportPath, _resV3Path); } } \ No newline at end of file