parent
							
								
									75abc82500
								
							
						
					
					
						commit
						6ae05aad01
					
				|  | @ -1,8 +0,0 @@ | |||
| fileFormatVersion: 2 | ||||
| guid: 11c5c61708cec45b3886f7c93951d083 | ||||
| folderAsset: yes | ||||
| DefaultImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
|  | @ -1,6 +0,0 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|           package="com.guru.unity.sdk.android.res.network.security" | ||||
|           android:versionCode="1" | ||||
|           android:versionName="1.0"> | ||||
| </manifest> | ||||
|  | @ -1,7 +0,0 @@ | |||
| fileFormatVersion: 2 | ||||
| guid: 038b314e2834b4b3f80537a3c7832481 | ||||
| DefaultImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
|  | @ -1,2 +0,0 @@ | |||
| target=android-9 | ||||
| android.library=`true` | ||||
|  | @ -1,7 +0,0 @@ | |||
| fileFormatVersion: 2 | ||||
| guid: 3a35ac1e970714224ba4adaae5756f10 | ||||
| DefaultImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
|  | @ -1,8 +0,0 @@ | |||
| fileFormatVersion: 2 | ||||
| guid: c6c2e979b6e21424a8c8807754828741 | ||||
| folderAsset: yes | ||||
| DefaultImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
|  | @ -1,3 +0,0 @@ | |||
| fileFormatVersion: 2 | ||||
| guid: 29db8462008d4d8d9220c83bf5dcd6e0 | ||||
| timeCreated: 1706057866 | ||||
|  | @ -65,7 +65,7 @@ namespace Guru.Editor | |||
|         { | ||||
|             if (File.Exists(TargetFullPath)) return; | ||||
|              | ||||
|             var path = GuruEditorHelper.GetFilePath($"{nameof(AndroidManifestMod)} t:Script"); | ||||
|             var path = GuruEditorHelper.GetAssetPath(nameof(AndroidManifestMod), "Script", true); | ||||
|             if (!string.IsNullOrEmpty(path)) | ||||
|             { | ||||
|                 var from = Path.GetFullPath($"{path}/../../Files/AndroidManifest.txt"); | ||||
|  |  | |||
|  | @ -95,7 +95,7 @@ namespace Guru.Editor | |||
| 
 | ||||
|         private static string GetMoveFilePath(string fileName) | ||||
|         { | ||||
|             var path = GuruEditorHelper.GetFilePath($"{nameof(AndroidProjectMod)} t:Script"); | ||||
|             var path = GuruEditorHelper.GetAssetPath(nameof(AndroidProjectMod), "Script", true); | ||||
|             var files = Path.GetFullPath($"{path}/../../Files"); | ||||
|             return $"{files}/{fileName}"; | ||||
|         } | ||||
|  |  | |||
|  | @ -96,7 +96,7 @@ namespace Guru.Editor | |||
|         } | ||||
|          | ||||
| 
 | ||||
|         private static bool  DeployAllIcons(Texture2D source, Color color) | ||||
|         private static bool DeployAllIcons(Texture2D source, Color color) | ||||
|         { | ||||
|             var dir = AndroidLibHelper.CreateLibRoot(PackageName, LibName); | ||||
|             string path = ""; | ||||
|  | @ -145,6 +145,8 @@ namespace Guru.Editor | |||
|                 doc.SetMetadata("com.google.firebase.messaging.default_notification_channel_id", "@string/default_notification_channel_id"); | ||||
|                 doc.Save(); | ||||
|                 Debug.Log("<color=#88ff00> --- Push Icon Build Success --- </color>"); | ||||
|                  | ||||
|                 AssetDatabase.Refresh(); | ||||
|                 return true; | ||||
|             } | ||||
|              | ||||
|  |  | |||
|  | @ -6,38 +6,43 @@ namespace Guru.Editor | |||
|      | ||||
|     public class AndroidResMod | ||||
|     { | ||||
|         private static readonly string ResName = "GuruNetworkSecurity"; | ||||
|         private static string ResFullPath = Path.Combine(Application.dataPath, $"Plugins/Android/{ResName}.androidlib"); | ||||
|         private static string OldSecurityXml = Path.Combine(Application.dataPath, "Plugins/Android/res/xml/network_security_config.xml"); | ||||
|         private static readonly string NetworkSecurityXmlName = "network_security_config.xml"; | ||||
|         private static readonly string LibNetworkSecurity = "GuruNetworkSecurity"; | ||||
|         private static readonly string LibNetworkSecurityPackageName = "com.guru.unity.sdk.android.res.network.security"; | ||||
|         private static string OldSecurityXml = Path.Combine(Application.dataPath, $"Plugins/Android/res/xml/{NetworkSecurityXmlName}"); | ||||
|          | ||||
|         /// <summary> | ||||
|         /// 应用补丁 | ||||
|         /// </summary> | ||||
|         public static void Apply() | ||||
|         { | ||||
|             DeployAndroidRes(); | ||||
|             DeployNetworkSecurity(); | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|         private static void DeployAndroidRes() | ||||
|         /// <summary> | ||||
|         /// 部署网络安全配置 | ||||
|         /// </summary> | ||||
|         private static void DeployNetworkSecurity() | ||||
|         { | ||||
|             if(File.Exists(OldSecurityXml)) File.Delete(OldSecurityXml); | ||||
|              | ||||
|             var spath = GuruEditorHelper.GetFilePath($"{nameof(AndroidResMod)} t:Script"); | ||||
|             if (!string.IsNullOrEmpty(spath)) | ||||
|             { | ||||
|                 var from = Path.GetFullPath($"{spath}/../../Files/sdk_res"); | ||||
|                 if (Directory.Exists(from)) | ||||
|                 { | ||||
|                     var to = ResFullPath; | ||||
|                     if (Directory.Exists(to)) | ||||
|                     { | ||||
|                         FileUtil.DeleteFileOrDirectory(ResFullPath); | ||||
|                     } | ||||
|                     FileUtil.CopyFileOrDirectory(from, to); | ||||
|                 } | ||||
|             } | ||||
|             if(File.Exists(OldSecurityXml)) File.Delete(OldSecurityXml); // 清理旧文件 | ||||
| 
 | ||||
|             if (!AndroidLibHelper.IsEmbeddedAndroidLibExists(LibNetworkSecurity)) | ||||
|             { | ||||
|                 string dir = AndroidLibHelper.CreateLibRoot(LibNetworkSecurityPackageName, LibNetworkSecurity); | ||||
|                 var d = GuruEditorHelper.GetAssetPath(nameof(AndroidResMod), "Script", true); | ||||
|                 if (!string.IsNullOrEmpty(d)) | ||||
|                 { | ||||
|                     var from = $"{Directory.GetParent(d)?.FullName ?? ""}/Files/{NetworkSecurityXmlName}"; | ||||
|                     if (File.Exists(from)) | ||||
|                     { | ||||
|                         string toDir = $"{dir}/res/xml"; | ||||
|                         if(!Directory.Exists(toDir))Directory.CreateDirectory(toDir); | ||||
|                         string to = $"{toDir}/{NetworkSecurityXmlName}"; | ||||
|                         FileUtil.CopyFileOrDirectory(from, to); | ||||
|                     } | ||||
|                 } | ||||
| 
 | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,19 +2,34 @@ namespace Guru.Editor | |||
| { | ||||
|     using UnityEditor; | ||||
|     using UnityEngine; | ||||
|     using System; | ||||
|     using System.IO; | ||||
|      | ||||
|     public class GuruEditorHelper | ||||
|     { | ||||
|         public static string GetFilePath(string filter) | ||||
|         public static string GetAssetPath(string filter, bool useFullPath = false) | ||||
|         { | ||||
|             var guids = AssetDatabase.FindAssets(filter); | ||||
|             string path = ""; | ||||
|             string fullPath = ""; | ||||
|             if (guids != null && guids.Length > 0) | ||||
|             { | ||||
|                 var path = AssetDatabase.GUIDToAssetPath(guids[0]); | ||||
|                 return path; | ||||
|                 path = AssetDatabase.GUIDToAssetPath(guids[0]); | ||||
|                 fullPath = path.Replace("Assets", Application.dataPath); | ||||
|                 if (File.Exists(fullPath)) | ||||
|                 { | ||||
|                     return useFullPath? fullPath : path; | ||||
|                 } | ||||
|             } | ||||
|             return ""; | ||||
|         } | ||||
|          | ||||
|         public static string GetAssetPath(string fileName, string typeName = "", bool useFullPath = false) | ||||
|         { | ||||
|             var filter = fileName; | ||||
|             if(!string.IsNullOrEmpty(typeName)) filter = $"{fileName} t:{typeName}"; | ||||
|             return GetAssetPath(filter, useFullPath); | ||||
|         } | ||||
| 
 | ||||
|         public static void OpenPath(string path) | ||||
|         { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue