2022-09-22 08:56:07 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
using UnityEditorInternal;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2022-10-09 03:25:56 +08:00
|
|
|
|
|
2022-09-22 08:56:07 +08:00
|
|
|
|
namespace HybridCLR.Editor
|
|
|
|
|
{
|
|
|
|
|
public static class SettingsUtil
|
|
|
|
|
{
|
2022-10-09 03:25:56 +08:00
|
|
|
|
public static bool Enable => HybridCLRGlobalSettings.Instance.enable;
|
2022-09-22 08:56:07 +08:00
|
|
|
|
|
|
|
|
|
public static string PackageName { get; } = "com.focus-creative-games.hybridclr_unity";
|
|
|
|
|
|
2022-09-26 11:54:14 +08:00
|
|
|
|
public static string HybridCLRDataPathInPackage => $"Packages/{PackageName}/Data~";
|
2022-09-22 08:56:07 +08:00
|
|
|
|
|
|
|
|
|
public static string TemplatePathInPackage => $"{HybridCLRDataPathInPackage}/Templates";
|
|
|
|
|
|
|
|
|
|
public static string ProjectDir { get; } = Directory.GetParent(Application.dataPath).ToString();
|
|
|
|
|
|
|
|
|
|
public static string ScriptingAssembliesJsonFile { get; } = "ScriptingAssemblies.json";
|
|
|
|
|
|
|
|
|
|
public static string GlobalgamemanagersBinFile { get; } = "globalgamemanagers";
|
|
|
|
|
|
|
|
|
|
public static string Dataunity3dBinFile { get; } = "data.unity3d";
|
|
|
|
|
|
2022-10-08 12:35:34 +08:00
|
|
|
|
public static string HotUpdateDllsRootOutputDir => $"{HybridCLRDataDir}/HotUpdateDlls";
|
2022-09-22 08:56:07 +08:00
|
|
|
|
|
2022-10-08 12:35:34 +08:00
|
|
|
|
public static string HybridCLRDataDir => $"{ProjectDir}/HybridCLRData";
|
2022-09-22 08:56:07 +08:00
|
|
|
|
|
2022-10-08 12:35:34 +08:00
|
|
|
|
public static string AssembliesPostIl2CppStripDir => $"{HybridCLRDataDir}/AssembliesPostIl2CppStrip";
|
2022-09-22 08:56:07 +08:00
|
|
|
|
|
|
|
|
|
public static string LocalUnityDataDir => $"{HybridCLRDataDir}/LocalIl2CppData-{Application.platform}";
|
|
|
|
|
|
|
|
|
|
public static string LocalIl2CppDir => $"{LocalUnityDataDir}/il2cpp";
|
|
|
|
|
|
|
|
|
|
public static string MethodBridgeCppDir => $"{LocalIl2CppDir}/libil2cpp/hybridclr/interpreter";
|
|
|
|
|
|
|
|
|
|
public static string Il2CppBuildCacheDir { get; } = $"{ProjectDir}/Library/Il2cppBuildCache";
|
|
|
|
|
|
2022-10-08 12:35:34 +08:00
|
|
|
|
public static string GetHotUpdateDllsOutputDirByTarget(BuildTarget target)
|
2022-09-22 08:56:07 +08:00
|
|
|
|
{
|
2022-10-08 12:35:34 +08:00
|
|
|
|
return $"{HotUpdateDllsRootOutputDir}/{target}";
|
2022-09-22 08:56:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GetAssembliesPostIl2CppStripDir(BuildTarget target)
|
|
|
|
|
{
|
|
|
|
|
return $"{AssembliesPostIl2CppStripDir}/{target}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class AssemblyDefinitionData
|
|
|
|
|
{
|
|
|
|
|
public string name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 所有热更新dll列表。放到此列表中的dll在打包时OnFilterAssemblies回调中被过滤。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static List<string> HotUpdateAssemblyNames
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2022-10-09 03:25:56 +08:00
|
|
|
|
var gs = HybridCLRGlobalSettings.Instance;
|
2022-09-22 08:56:07 +08:00
|
|
|
|
var hotfixAssNames = (gs.hotUpdateAssemblyDefinitions ?? Array.Empty<AssemblyDefinitionAsset>()).Select(ad => JsonUtility.FromJson<AssemblyDefinitionData>(ad.text));
|
|
|
|
|
|
|
|
|
|
var hotfixAssembles = new List<string>();
|
|
|
|
|
foreach (var assName in hotfixAssNames)
|
|
|
|
|
{
|
|
|
|
|
hotfixAssembles.Add(assName.name);
|
|
|
|
|
}
|
|
|
|
|
hotfixAssembles.AddRange(gs.hotUpdateAssemblies ?? Array.Empty<string>());
|
|
|
|
|
return hotfixAssembles.ToList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public static List<string> HotUpdateAssemblyFiles => HotUpdateAssemblyNames.Select(dll => dll + ".dll").ToList();
|
|
|
|
|
|
2022-10-09 03:25:56 +08:00
|
|
|
|
public static HybridCLRGlobalSettings GlobalSettings => HybridCLRGlobalSettings.Instance;
|
2022-09-22 08:56:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|