2024-05-31 08:03:02 +00:00
|
|
|
using System.IO;
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace Guru
|
|
|
|
|
{
|
|
|
|
|
public class AdjustSignatureHelper
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private static readonly string AndroidLib = "adjust-android-signature-3.13.1.aar";
|
|
|
|
|
private static readonly string iOSLib = "AdjustSigSdk.a";
|
|
|
|
|
|
|
|
|
|
public static void DeployFiles()
|
|
|
|
|
{
|
|
|
|
|
var dir = GetParentDir();
|
|
|
|
|
var files = $"{dir}/Files";
|
|
|
|
|
if (Directory.Exists(files))
|
|
|
|
|
{
|
|
|
|
|
string from, to;
|
|
|
|
|
bool res;
|
|
|
|
|
from = $"{files}/{AndroidLib}.f";
|
|
|
|
|
to = $"{Application.dataPath}/Plugins/Android/{AndroidLib}";
|
2024-08-01 07:40:34 +00:00
|
|
|
res = CopyFile(from, to); // 无需覆盖
|
2024-05-31 08:03:02 +00:00
|
|
|
if (res) Debug.Log($"Copy <color=#88ff00>{AndroidLib} to {to}</color> success...");
|
|
|
|
|
from = $"{files}/{AndroidLib}.f.meta";
|
|
|
|
|
to = $"{Application.dataPath}/Plugins/Android/{AndroidLib}.meta";
|
2024-08-01 07:40:34 +00:00
|
|
|
CopyFile(from, to); // 无需覆盖
|
2024-05-31 08:03:02 +00:00
|
|
|
|
|
|
|
|
from = $"{files}/{iOSLib}.f";
|
|
|
|
|
to = $"{Application.dataPath}/Plugins/iOS/{iOSLib}";
|
2024-08-01 07:40:34 +00:00
|
|
|
res = CopyFile(from, to); // 无需覆盖
|
2024-05-31 08:03:02 +00:00
|
|
|
if (res) Debug.Log($"Copy <color=#88ff00>{iOSLib} to {to}</color> success...");
|
|
|
|
|
from = $"{files}/{iOSLib}.f.meta";
|
|
|
|
|
to = $"{Application.dataPath}/Plugins/iOS/{iOSLib}.meta";
|
2024-08-01 07:40:34 +00:00
|
|
|
CopyFile(from, to); // 无需覆盖
|
2024-05-31 08:03:02 +00:00
|
|
|
|
|
|
|
|
AssetDatabase.Refresh();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Debug.Log($"<color=red>Files not found: {files}</color>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static string GetParentDir()
|
|
|
|
|
{
|
|
|
|
|
var guids = AssetDatabase.FindAssets(nameof(AdjustSignatureHelper));
|
|
|
|
|
if (guids != null && guids.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
var path = AssetDatabase.GUIDToAssetPath(guids[0]);
|
|
|
|
|
var dir = Directory.GetParent(Path.GetFullPath(path));
|
|
|
|
|
return dir.FullName;
|
|
|
|
|
}
|
|
|
|
|
return Path.GetFullPath($"{Application.dataPath}/../Packages/com.guru.unity.sdk.core/Runtime/GuruAdjust/Editor/Signature");
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-01 07:40:34 +00:00
|
|
|
private static bool CopyFile(string from, string to, bool overwrite = false)
|
2024-05-31 08:03:02 +00:00
|
|
|
{
|
2024-08-01 07:40:34 +00:00
|
|
|
if (File.Exists(to) && !overwrite)
|
2024-05-31 08:03:02 +00:00
|
|
|
{
|
2024-08-01 07:40:34 +00:00
|
|
|
// 如果目标文件存在, 且不允许覆写, 则不进行拷贝
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (File.Exists(from))
|
|
|
|
|
{
|
|
|
|
|
// 确保拷贝目录存在
|
|
|
|
|
var destDir = Directory.GetParent(to);
|
|
|
|
|
if(destDir != null && !destDir.Exists) destDir.Create();
|
2024-05-31 08:03:02 +00:00
|
|
|
|
2024-08-01 07:40:34 +00:00
|
|
|
File.Copy(from, to, overwrite);
|
2024-05-31 08:03:02 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-01 07:40:34 +00:00
|
|
|
Debug.Log($"<colo=red>File not found: {from}...</color>");
|
2024-05-31 08:03:02 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|