com.guru.unity.sdk/Editor/GuruManager/Helper/AndroidResMod.cs

46 lines
1.3 KiB
C#

namespace Guru.Editor
{
using System.IO;
using UnityEditor;
using UnityEngine;
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");
/// <summary>
/// 应用补丁
/// </summary>
public static void Apply()
{
DeployAndroidRes();
}
private static void DeployAndroidRes()
{
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);
}
}
}
}
}