breakpoint
before update unity version
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.Mod
|
||||
@@ -8,21 +14,57 @@ namespace BITKit.Mod
|
||||
public class UnityModService : MonoBehaviour
|
||||
{
|
||||
[SerializeReference,SubclassSelector] private IReference[] referencedAssemblies;
|
||||
private void Start()
|
||||
[SerializeField] private bool loadLocalPackageOnStart;
|
||||
private async void Start()
|
||||
{
|
||||
foreach (var x in referencedAssemblies)
|
||||
{
|
||||
var dllName = x.Value.Contains(".dll") ? x.Value : $"{x.Value}.dll";
|
||||
#if UNITY_EDITOR
|
||||
var dll = System.IO.Path.Combine(Environment.CurrentDirectory, "Library", "ScriptAssemblies",dllName);
|
||||
|
||||
var folder = EditorApplication.applicationPath;
|
||||
folder = Path.GetDirectoryName(folder);
|
||||
if(File.Exists(dll) is false)
|
||||
{
|
||||
dll = Path.Combine(folder,"Data", "MonoBleedingEdge", "lib","mono","unityjit-win32",dllName);
|
||||
}
|
||||
if (File.Exists(dll) is false)
|
||||
{
|
||||
dll = Path.Combine(folder,"Data", "MonoBleedingEdge", "lib","mono","unityjit-win32","Facades",dllName);
|
||||
}
|
||||
#else
|
||||
var dll = System.IO.Path.Combine(Environment.CurrentDirectory,$"{Application.productName}_Data", "Managed", dllName);
|
||||
#endif
|
||||
BITSharp.ReferencedAssemblies.Add(dll);
|
||||
|
||||
if (System.IO.File.Exists(dll) is false)
|
||||
{
|
||||
BIT4Log.Warning<UnityModService>($"未找到:{dll}");
|
||||
}
|
||||
BITSharp.ReferencedAssemblies.Add(@$"""{dll}""");
|
||||
}
|
||||
ModService.Initialize();
|
||||
|
||||
try
|
||||
{
|
||||
ModService.Initialize();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BIT4Log.Warning<UnityModService>("初始化失败");
|
||||
BIT4Log.LogException(e);
|
||||
return;
|
||||
}
|
||||
|
||||
destroyCancellationToken.Register(ModService.Dispose);
|
||||
|
||||
if (!loadLocalPackageOnStart) return;
|
||||
|
||||
var packages = await ModService.SearchPackages();
|
||||
if (destroyCancellationToken.IsCancellationRequested) return;
|
||||
foreach (var package in packages)
|
||||
{
|
||||
await ModService.LoadFromPackage(package.PackagePath);
|
||||
if (destroyCancellationToken.IsCancellationRequested) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user