mirror of
https://github.com/focus-creative-games/hybridclr_unity.git
synced 2026-11-19 14:52:41 +08:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7e74e59637 | |||
| e48a7beb95 | |||
| 9790036a2f | |||
| ea9196e8c3 | |||
| 6cadd24d10 | |||
| 9b2cbbf1a7 | |||
| ab71cfa6cf | |||
| e61ff2296f | |||
| 635dc7dd1e | |||
| 0762becc28 | |||
| 52f07bc8b3 | |||
| baa70f8eb9 | |||
| 8d0476c2c9 |
@@ -2,23 +2,23 @@
|
||||
"versions": [
|
||||
{
|
||||
"unity_version":"2022.3.x",
|
||||
"hybridclr" : { "tag":"v9.0.1"},
|
||||
"il2cpp_plus": { "tag":"v2022.3.x-9.0.1"}
|
||||
"hybridclr" : { "tag":"v9.1.0"},
|
||||
"il2cpp_plus": { "tag":"v2022.3.x-9.1.0"}
|
||||
},
|
||||
{
|
||||
"unity_version":"2022.3.x-tuanjie",
|
||||
"hybridclr" : { "tag":"v9.0.1"},
|
||||
"il2cpp_plus": { "tag":"v2022.3.x-tuanjie-9.0.1"}
|
||||
"hybridclr" : { "tag":"v9.1.0"},
|
||||
"il2cpp_plus": { "tag":"v2022.3.x-tuanjie-9.1.0"}
|
||||
},
|
||||
{
|
||||
"unity_version":"6000.0.x",
|
||||
"hybridclr" : { "tag":"v9.0.1"},
|
||||
"il2cpp_plus": { "tag":"v6000.0.x-9.0.1"}
|
||||
"hybridclr" : { "tag":"v9.1.0"},
|
||||
"il2cpp_plus": { "tag":"v6000.0.x-9.1.0"}
|
||||
},
|
||||
{
|
||||
"unity_version":"6000.3.x",
|
||||
"hybridclr" : { "tag":"v6000.3.x-9.0.1"},
|
||||
"il2cpp_plus": { "tag":"v6000.3.x-9.0.1"}
|
||||
"hybridclr" : { "tag":"v6000.3.x-9.1.0"},
|
||||
"il2cpp_plus": { "tag":"v6000.3.x-9.1.0"}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
---
|
||||
name: hybridclr-aot-generic
|
||||
description: >-
|
||||
Handle HybridCLR AOT generics: supplementary metadata via LoadMetadataForAOTAssembly, saving stripped AOT dlls per platform, HomologousImageMode, AOTGenericReference, and MissingMethodException for an AOT generic method. Use when an AOT generic fails to instantiate, the user asks about metadata patching, List/Dictionary/async generics, or which supplementary dll to ship.
|
||||
---
|
||||
|
||||
# AOT generics
|
||||
|
||||
Docs: `guide/build/aotgeneric.md` and `start/generic.md` in the HybridCLR documentation.
|
||||
|
||||
Generic types and methods **defined in hot-update assemblies** have no AOT restriction. The restriction is hot-update code using a generic **defined in an AOT assembly** (`List<T>`, `Dictionary<TKey,TValue>`, async state machines, and similar) when that instantiation was not generated in AOT. Typical log:
|
||||
|
||||
```text
|
||||
MissingMethodException: AOT generic method not instantiated in aot module
|
||||
```
|
||||
|
||||
## Default: supplementary metadata
|
||||
|
||||
The community edition uses supplementary metadata. Do not send the user to hand-written RefTypes unless they are chasing one instantiation or optimizing a hot path.
|
||||
|
||||
Patch the **AOT dll that contains the generic method**, not the dll that contains the generic argument. `List<SomeHotUpdateStruct>` needs `mscorlib.dll`, because the missing IL is `List<T>.Add`, not the struct.
|
||||
|
||||
```csharp
|
||||
// Call once before any hot-update code uses that AOT generic. Order among dlls does not matter.
|
||||
LoadImageErrorCode err = HybridCLR.RuntimeApi.LoadMetadataForAOTAssembly(dllBytes, HomologousImageMode.SuperSet);
|
||||
// Do not keep dllBytes. The API copies them.
|
||||
```
|
||||
|
||||
- Call it after player startup, or after hot-update dlls are loaded and before business code runs. The supplementary dlls can ship in the player (for example StreamingAssets) or with a hot update.
|
||||
- Call it on another thread if it stalls.
|
||||
- Loaded metadata uses several times the dll size and is not released. Memory-tight projects use the commercial full generic sharing build (no supplementary dlls), or run `AOTAssemblyMetadataStripper.Strip` to drop non-generic method metadata first.
|
||||
- `HybridCLR/Generate/AOTGenericReference` writes a conservative `PatchedAOTAssemblyList`. Load the whole list when memory is fine. Otherwise start with common dlls such as `mscorlib` and add a dll when a new AOT generic error appears. Supplementary dlls can themselves be hot-updated.
|
||||
|
||||
## Which dll
|
||||
|
||||
The player build copies stripped AOT dlls to `{project}/HybridCLRData/AssembliesPostIl2CppStrip/{target}`. `Generate/AotDlls` can also produce them by exporting a temp project.
|
||||
|
||||
- **Stripped dlls from different BuildTargets are not interchangeable.**
|
||||
- **Freeze the dlls from the shipped player.** Do not replace them with a newer Generate output on every hot update.
|
||||
- `HomologousImageMode.SuperSet`: a superset is enough. Stripped or original AOT dlls both work. Use this by default.
|
||||
- `HomologousImageMode.Consistent`: the bytes must match **that player build's** stripped dll. Original dlls do not work. `Generate/All` output often differs slightly from the real player, so Consistent fails more often.
|
||||
|
||||
## Generic sharing (optional)
|
||||
|
||||
After metadata is loaded, HybridCLR still prefers an il2cpp shared instantiation when one exists. Class type arguments share as `object`. Non-enum value types share only with themselves. Enums share with enums of the same underlying type. Value types do not share across different types the way classes do, so `List<HotUpdateStruct>` is not covered by an AOT `List<int>`.
|
||||
|
||||
Instantiations in `AOTGenericReferences.cs` are comments and are overwritten on regenerate. Copy any you want into another AOT file (for example `new List<object>()`). That is a performance optimization, not a requirement for correctness.
|
||||
|
||||
## Full generic sharing
|
||||
|
||||
Commercial editions only. It removes the size, memory, and interpreted-call cost of supplementary metadata. Do not switch the workflow to it unless the user has that edition.
|
||||
@@ -0,0 +1,48 @@
|
||||
---
|
||||
name: hybridclr-avoid-code-strip
|
||||
description: >-
|
||||
Keep Unity IL2CPP from stripping AOT types and methods that hot-update code calls: Generate/LinkXml, linkPreserveLevel, a hand-written Assets/link.xml, a real reference from the main project, and MissingMetadataChecker. Use for TypeLoadException, MissingMethodException that is not an AOT generic error, code stripping, link.xml, or Generate/LinkXml.
|
||||
---
|
||||
|
||||
# Avoid code stripping
|
||||
|
||||
Doc: `guide/build/codestriping.md` in the HybridCLR documentation.
|
||||
|
||||
If a stripped AOT type or method is called from hot-update code:
|
||||
|
||||
```text
|
||||
TypeLoadException: Could not load type 'Xxx' from assembly 'yyy'
|
||||
MissingMethodException: ...
|
||||
```
|
||||
|
||||
If the log says `AOT generic method not instantiated`, use `hybridclr-aot-generic`. link.xml does not fix that.
|
||||
|
||||
## Before the player build
|
||||
|
||||
Run `HybridCLR/Generate/All` before building the player. It includes `Generate/LinkXml`. LinkXml alone scans AOT references from the current hot-update dlls.
|
||||
|
||||
- Output is Settings `outputLinkFile`, default `Assets/HybridCLR/Generate/link.xml`.
|
||||
- **Do not** point `outputLinkFile` at a hand-maintained `Assets/link.xml`. Generation overwrites it.
|
||||
- `linkPreserveLevel`: default `PreserveAllOfDeclaringType` keeps the whole referenced type. Use `PreserveExactMember` only to shrink the player (referenced fields, methods, properties, and events). A later hot update that touches another member can then miss it.
|
||||
|
||||
## When link.xml has no effect
|
||||
|
||||
If the main project never references any type or method in an AOT assembly, Unity strips that assembly entirely and preserve entries are ignored. Reference one type or method from that dll in the main project.
|
||||
|
||||
`preserve all` on `UnityEngine.Debug` can hit a Unity bug. Since 6.1.0, generated link.xml skips that class. Do not add it back.
|
||||
|
||||
## Reserve types for later hot updates
|
||||
|
||||
`Generate/LinkXml` only covers references in the **current** hot-update dlls. Put types you will need later in a separate `Assets/link.xml`, or call them from the main project. Do not put them in the generated file.
|
||||
|
||||
## Check before publishing a hot update
|
||||
|
||||
Use the stripped AOT dll directory saved from the player build. Do not use `AssembliesPostIl2CppStrip` after a later `Generate/All` has refreshed it.
|
||||
|
||||
```csharp
|
||||
var checker = new HybridCLR.HotUpdate.MissingMetadataChecker(
|
||||
aotDirFromPlayerBuild, SettingsUtil.HotUpdateAssemblyNamesIncludePreserved);
|
||||
bool ok = checker.Check(hotUpdateDllPath); // false: the dll touches a stripped type or method
|
||||
```
|
||||
|
||||
The second argument is hot-update assembly names without `.dll`. If an Ultimate build also has DHE assemblies, include those names in the list.
|
||||
@@ -0,0 +1,51 @@
|
||||
---
|
||||
name: hybridclr-configure
|
||||
description: >-
|
||||
Configure HybridCLR Settings and PlayerSettings: enable, hot-update assembly lists, external dll search paths, link.xml output, linkPreserveLevel, incremental GC, and IL2CPP. Use when the user opens HybridCLR/Settings, edits ProjectSettings/HybridCLRSettings.asset, checks settings before a player build, or asks what a setting does.
|
||||
---
|
||||
|
||||
# Configure HybridCLR
|
||||
|
||||
Docs: `guide/setup/projectsettings.md` and `guide/setup/hybridclr-unity-package.md` in the HybridCLR documentation. Fields follow `Editor/Settings/HybridCLRSettings.cs` in this repo. The asset is `ProjectSettings/HybridCLRSettings.asset`.
|
||||
|
||||
How to split assemblies and create asmdefs is `hybridclr-hotupdate-assembly`. Do not expand that here.
|
||||
|
||||
## PlayerSettings
|
||||
|
||||
- Scripting Backend is **IL2CPP**. WebGL does not use this option. Since v2.4.0 the build check switches this automatically.
|
||||
- Api Compatibility Level is **.NET Framework**.
|
||||
- Incremental GC is allowed since v4.0.0. Older packages must turn it off.
|
||||
|
||||
## Hot-update lists
|
||||
|
||||
`hotUpdateAssemblyDefinitions` and `hotUpdateAssemblies` merge into the final hot-update dll list. **Do not put the same assembly in both.**
|
||||
|
||||
| Source | Where |
|
||||
|---|---|
|
||||
| asmdef | `hotUpdateAssemblyDefinitions` |
|
||||
| External dll, or `Assembly-CSharp` | `hotUpdateAssemblies`, name **without** `.dll` |
|
||||
|
||||
An empty list fails the player-build check. `IFilterBuildAssemblies` removes these dlls from the player build so they are not compiled into AOT.
|
||||
|
||||
## Settings
|
||||
|
||||
- `enable`: default true. Turning it off drops HybridCLR from the player. Also remove the main project's reference to `HybridCLR.Runtime`, or symbols such as `LoadMetadataForAOTAssembly` are missing.
|
||||
- `useGlobalIl2cpp`: default false. Keep the local `UNITY_IL2CPP_PATH`.
|
||||
- `hybridclrRepoURL` / `il2cppPlusRepoURL`: clone URLs for the installer. Default is gitee.
|
||||
- `preserveHotUpdateAssemblies`: names of hot-update dlls that do not exist yet (no `.dll`). The build does not check that the files exist, but it writes the names into `ScriptingAssemblies.json` so scripts can be attached to assets later. Do not list dlls that already exist.
|
||||
- `externalHotUpdateAssembliyDirs`: search paths for external hot-update dlls. The serialized name is spelled `Assembliy`. Do not rename it. Paths are relative to the **project root** (parent of Assets). Each entry is searched as `{dir}/{platform}` first, then `{dir}`. Earlier entries win. The dll name still goes in `hotUpdateAssemblies`.
|
||||
- `outputLinkFile`: output of `Generate/LinkXml`. Default `HybridCLR/Generate/link.xml`, relative to Assets. **Do not** point it at `Assets/link.xml`. Generation overwrites the file.
|
||||
- `linkPreserveLevel`: `PreserveAllOfDeclaringType` (default; keep every member of a referenced type) or `PreserveExactMember` (only referenced fields, methods, properties, and events; smaller).
|
||||
- `outputAOTGenericReferenceFile`: default `HybridCLR/Generate/AOTGenericReferences.cs`.
|
||||
- `maxGenericReferenceIteration` / `maxMethodBridgeGenericIteration`: generic scan iteration cap, default 10. Raise them only if the log shows the scan has not converged.
|
||||
|
||||
## Fixed output directories
|
||||
|
||||
These are not settings:
|
||||
|
||||
- Hot-update dlls: `{project}/HybridCLRData/HotUpdateDlls/{target}`
|
||||
- Stripped AOT dlls: `{project}/HybridCLRData/AssembliesPostIl2CppStrip/{target}`
|
||||
|
||||
## What the package does during a player build
|
||||
|
||||
Do not hand-edit these: set or clear the process `UNITY_IL2CPP_PATH` from `enable`; strip hot-update assemblies from the build; write hot-update dll names into the assembly list; copy stripped AOT dlls to the directory above.
|
||||
@@ -0,0 +1,61 @@
|
||||
---
|
||||
name: hybridclr-hotupdate-assembly
|
||||
description: >-
|
||||
Split, create, compile, and load HybridCLR hot-update assemblies: asmdefs and Assembly-CSharp, forbidding AOT references to hot-update code, CompileDll, Assembly.Load order, and calling hot-update entry points from the main project. Use when the user adds a hot-update module, splits AOT and hot-update code, compiles HotUpdate.dll, loads a dll, hits a duplicate load, or a player build references a hot-update assembly.
|
||||
---
|
||||
|
||||
# Hot-update assemblies
|
||||
|
||||
Docs: `guide/setup/hotupdateassemblysetting.md`, `guide/build/compileassembly.md`, and `guide/build/runhotupdatecodes.md` in the HybridCLR documentation. Settings fields are in `hybridclr-configure`.
|
||||
|
||||
## Split
|
||||
|
||||
Keep at least one **AOT** assembly for startup and for downloading hot-update content. Hot-update code must live in its own assembly.
|
||||
|
||||
Two common layouts:
|
||||
|
||||
- `Assembly-CSharp` stays AOT, and other code is split into AOT and hot-update asmdefs. **Turn off Auto Referenced on hot-update asmdefs.** `Assembly-CSharp` references every other assembly, so Auto Referenced easily creates an AOT reference to a hot-update dll and the player build fails.
|
||||
- `Assembly-CSharp` itself is hot-update. Put the name in `hotUpdateAssemblies` without `.dll`.
|
||||
|
||||
AOT assemblies must not reference hot-update assemblies. Hot-update assemblies may reference each other. Load dependencies first.
|
||||
|
||||
## Create
|
||||
|
||||
1. Create a folder, for example `Assets/HotUpdate`.
|
||||
2. Create → Assembly Definition, named like the module.
|
||||
3. In `HybridCLR/Settings`, put asmdefs in `hotUpdateAssemblyDefinitions`. Put assemblies that have no asmdef in `hotUpdateAssemblies` by name. Do not add the same assembly to both.
|
||||
4. For a prebuilt dll outside the default output directory, put the name in `hotUpdateAssemblies` and the directory in `externalHotUpdateAssembliyDirs` (relative to the project root).
|
||||
|
||||
## Compile
|
||||
|
||||
Do not ship dlls from `Library/ScriptAssemblies`. Those are compiled for the Editor target and depend on the debugger setting.
|
||||
|
||||
- Use `HybridCLR/Compile/{platform}`, or `HybridCLR.Editor.Commands.CompileDllCommand.CompileDll(BuildTarget)`.
|
||||
- Output: `{project}/HybridCLRData/HotUpdateDlls/{target}`. Compile once per BuildTarget so defines such as `UNITY_ANDROID` match.
|
||||
- `HybridCLR/Generate/All` also compiles hot-update dlls. **After the player is shipped**, a normal hot update only recompiles and publishes the dll. Do not run Generate every time.
|
||||
|
||||
When copying into assets, add a `.bytes` extension (`HotUpdate.dll.bytes`).
|
||||
|
||||
## Load
|
||||
|
||||
```csharp
|
||||
// The runtime copies the bytes. Do not keep assemblyData or pdb after the call returns.
|
||||
Assembly ass = Assembly.Load(assemblyData);
|
||||
// Since v6.4.0, symbols can load with the assembly:
|
||||
Assembly ass2 = Assembly.Load(assemblyData, pdbSymbolData);
|
||||
```
|
||||
|
||||
- `Assembly.Load` multiple dlls in dependency order. Move the call to another thread if it stalls the main thread.
|
||||
- **Do not Load again in the Editor.** The assemblies are already in the domain. Wrap the load in `#if !UNITY_EDITOR` and, in the Editor, find them with `AppDomain.CurrentDomain.GetAssemblies()`.
|
||||
- An assembly missing from the hot-update lists is compiled into AOT. Loading it again at runtime is a duplicate load.
|
||||
|
||||
## Call hot-update code from AOT
|
||||
|
||||
The main project cannot reference hot-update types directly. Typical entry points:
|
||||
|
||||
- Reflection: `ass.GetType(...).GetMethod(...).Invoke`
|
||||
- `Delegate.CreateDelegate`, or `Activator.CreateInstance` cast to an interface defined in AOT
|
||||
- `go.AddComponent(type)` after the dll is loaded
|
||||
- Instantiate a prefab or scene packed in an AssetBundle (extra rules for scripts on assets are in `hybridclr-monobehaviour`)
|
||||
|
||||
Load the dll **before** loading an AssetBundle that should restore those scripts.
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
name: hybridclr-monobehaviour
|
||||
description: >-
|
||||
Use MonoBehaviour and ScriptableObject from HybridCLR hot-update code: AddComponent, scripts on assets, ScriptingAssemblies.json, AssetBundle load order, Script Missing, and the GetComponent(string) limitation. Use when the user attaches a hot-update script to a prefab or scene, hits Script Missing, or asks about the hot-update MonoBehaviour workflow.
|
||||
---
|
||||
|
||||
# Hot-update MonoBehaviour
|
||||
|
||||
Doc: `guide/features/monobehaviour.md` in the HybridCLR documentation. Registering the assembly is `hybridclr-hotupdate-assembly`.
|
||||
|
||||
`AddComponent<T>()` and `AddComponent(Type)` work after that dll has been `Assembly.Load`ed.
|
||||
|
||||
## Scripts and ScriptableObjects on assets
|
||||
|
||||
Deserialization needs all of the following:
|
||||
|
||||
1. The dll that contains the script is already loaded.
|
||||
2. The asset is loaded from an AssetBundle (Addressables and other AB-based systems count). A script on a Resources asset or a scene that ships in the player becomes **Script Missing**. Building that asset into an AssetBundle and then placing the bundle in Resources is fine.
|
||||
3. The dll name is in the generated `ScriptingAssemblies.json`. Hot-update dlls are removed by `IFilterBuildAssemblies`, so they are not listed on their own. `PatchScriptingAssemblyList` writes names from `hotUpdateAssemblyDefinitions`, `hotUpdateAssemblies`, and `preserveHotUpdateAssemblies`. Unlisted assemblies are not restored.
|
||||
|
||||
The hot-update dll itself may live in an AssetBundle, as a raw file, or in an encrypted package. `Assembly.Load` it **before** loading assets that contain the scripts.
|
||||
|
||||
Do not rename these assemblies after release. The assembly list is baked into the player and cannot be hot-updated.
|
||||
|
||||
## Known limits
|
||||
|
||||
- `GetComponent(string)` cannot find a hot-update script that was restored from a hot-update asset. Use `GetComponent<T>()` or `GetComponent(typeof(T))`. Components added with `AddComponent` in code are not affected.
|
||||
- Do not disable TypeTree when building AssetBundles. Script signature checks then fail and a normal load fails. If TypeTree must be off, call `AssetBundleCreateRequest.SetEnableCompatibilityChecks(false)` through reflection and keep code and asset versions matched. A mismatch can crash.
|
||||
@@ -0,0 +1,39 @@
|
||||
---
|
||||
name: hybridclr-monopinvokecallback
|
||||
description: >-
|
||||
Reserve MonoPInvokeCallback and ReversePInvokeWrapper slots for HybridCLR hot-update methods: ReversePInvokeWrapperGenerationAttribute, Generate/ReversePInvokeWrapper, and the lack of automatic marshaling for string and other non-blittable arguments. Use for MonoPInvokeCallback, xlua/tolua/puerts callbacks, too few wrappers, or a crash when native code calls hot-update C#.
|
||||
---
|
||||
|
||||
# MonoPInvokeCallback
|
||||
|
||||
Doc: `guide/features/monopinvokecallback.md` in the HybridCLR documentation. Choosing a Lua, JS, or Python stack is `hybridclr-script-language`.
|
||||
|
||||
A static method with `[MonoPInvokeCallback]` needs a C++ wrapper before `Marshal.GetFunctionPointerForDelegate` can return a pointer. Platforms that cannot JIT, including iOS, cannot create that wrapper at runtime. Generate it in the player build with `HybridCLR/Generate/ReversePInvokeWrapper` (`Generate/All` includes it).
|
||||
|
||||
## Reserve a count
|
||||
|
||||
Generating one wrapper per current callback runs out as soon as a later hot update adds another callback.
|
||||
|
||||
Add `[ReversePInvokeWrapperGeneration(preserveCount)]` (`HybridCLR` namespace) on the callback. **Counts are per signature:**
|
||||
|
||||
wrappers for a signature = sum of `preserveCount` on that signature + number of callbacks of that signature that do not have the attribute.
|
||||
|
||||
```csharp
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
delegate int LuaFunction(IntPtr luaState);
|
||||
|
||||
[ReversePInvokeWrapperGeneration(10)]
|
||||
[MonoPInvokeCallback(typeof(LuaFunction))]
|
||||
public static int LuaCallback(IntPtr luaState) => 0;
|
||||
```
|
||||
|
||||
The reservation is fixed in the player. Hot updates can only consume wrappers that were already generated.
|
||||
|
||||
## Argument marshaling
|
||||
|
||||
HybridCLR does **not** marshal arguments when calling these callbacks. `int` and `float` work. `string` arrives as `char*` and using it as a string crashes.
|
||||
|
||||
Two options:
|
||||
|
||||
1. Put the callback in AOT and call into hot-update code from there. The AOT wrapper has il2cpp marshaling.
|
||||
2. Take `IntPtr` in the hot-update callback and convert with `Marshal.PtrToStringUTF8`. Do the same for other non-primitive types that need marshaling.
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
name: hybridclr-script-language
|
||||
description: >-
|
||||
Run HybridCLR next to Lua, JavaScript/TypeScript, or Python: prefer ZLua and ZenTS; xlua, tolua, slua, and puerts need reserved ReversePInvokeWrappers and generated binding code moved into a hot-update assembly. Use when the user combines HybridCLR with lua, js, ts, python, xlua, tolua, puerts, zlua, or ZenTS, or is moving script hot update to C#.
|
||||
---
|
||||
|
||||
# Script languages
|
||||
|
||||
Doc: `guide/features/workwithscriptlanguage.md` in the HybridCLR documentation. Wrapper reservation rules are in `hybridclr-monopinvokecallback`. Do not restate them here.
|
||||
|
||||
HybridCLR is native C# hot update. It can sit beside an existing script stack while gameplay moves back to C#.
|
||||
|
||||
## Prefer ZLua / ZenTS
|
||||
|
||||
For a new scripting layer, use the official stacks instead of xlua or puerts.
|
||||
|
||||
- [ZLua](https://github.com/focus-creative-games/zlua) for Lua
|
||||
- [ZenTS](https://github.com/focus-creative-games/zen-ts) for JavaScript / TypeScript
|
||||
|
||||
They talk to il2cpp directly. They do not need `[MonoPInvokeCallback]` or a wrapper quota. Use the path below only when the project is already on xlua, tolua, or puerts.
|
||||
|
||||
## Other script stacks
|
||||
|
||||
xlua, tolua, slua, puerts, and similar binders call C# from native through `[MonoPInvokeCallback]`. Before the player build:
|
||||
|
||||
1. Add `[ReversePInvokeWrapperGeneration(n)]` on signatures that will grow. The count must cover later hot updates, not only the callbacks that exist now.
|
||||
2. Run `HybridCLR/Generate/All` (includes `ReversePInvokeWrapper`).
|
||||
3. Put generated binding code in a **hot-update** assembly and register that assembly. Do not leave it where it will be compiled as AOT.
|
||||
|
||||
### xlua
|
||||
|
||||
xlua emits code into global `Assembly-CSharp` and ties it to runtime types with partial classes. The generated output usually has to be edited before it can live in a hot-update assembly. [HybridCLRXlua](https://gitee.com/ldr123/HybridCLRXlua) is a working reference. Follow that project's assembly split. Do not assume the stock xlua generator supports HybridCLR as-is.
|
||||
|
||||
### tolua, slua, puerts
|
||||
|
||||
Check three things: enough wrappers are reserved, generated code is in the hot-update module, and registration runs after the hot-update dll is loaded.
|
||||
@@ -0,0 +1,47 @@
|
||||
---
|
||||
name: hybridclr-setup
|
||||
description: >-
|
||||
Install and initialize com.code-philosophy.hybridclr: pick a matching Unity and package version, add the package from git or a local Packages folder, run HybridCLR/Installer, and recover from git or network failures. Use when the user installs, upgrades, or initializes HybridCLR, or when install fails, git clone fails, or the player still uses stock IL2CPP.
|
||||
---
|
||||
|
||||
# Install HybridCLR
|
||||
|
||||
Docs: `guide/setup/install.md` and `guide/setup/supported-platforms-and-unity-versions.md` in the HybridCLR documentation. Package and il2cpp branches come from this repo's `Data~/hybridclr_version.json`. Do not change those branches from memory.
|
||||
|
||||
## Versions
|
||||
|
||||
- **v9.x** supports Unity **2022.3.x** and **6000.x** except 6000.5.x. Use **v8.x** for 2019.4, 2020.3, and 2021.3.
|
||||
- The package name is `com.code-philosophy.hybridclr`. Before v3.0.0 it was `com.focus-creative-games.hybridclr_unity`.
|
||||
- Standalone players need the **IL2CPP** module (`Windows Build Support (IL2CPP)` or `Mac Build Support (IL2CPP)`). An editor that only has the iOS or Android module cannot build that Standalone player. Exporting an iOS Xcode project does not require a local signing certificate.
|
||||
|
||||
## Install the package
|
||||
|
||||
Either:
|
||||
|
||||
1. Package Manager → Add package from git URL: `https://gitee.com/focus-creative-games/hybridclr_unity.git` or the GitHub repo with the same name. Pin a tag with `#{tag}`, for example `#v9.0.0`.
|
||||
2. Place the repo at `Packages/com.code-philosophy.hybridclr`.
|
||||
|
||||
## Initialize (required)
|
||||
|
||||
Installing the package does not replace libil2cpp.
|
||||
|
||||
1. **git** must be installed. Restart the Unity Editor and Hub after installing git. Restart the machine if git is on PATH but the installer still cannot find it.
|
||||
2. Open `HybridCLR/Installer...` and use the default remote install. Success prints `安装成功` and the status becomes installed.
|
||||
3. The installer clones the `hybridclr` and `il2cpp_plus` branches listed in `Data~/hybridclr_version.json` for the current Unity major version. Do not edit that file unless the user explicitly wants a non-matching version.
|
||||
4. If git or the network is unavailable, merge a local libil2cpp that already contains HybridCLR, enable "copy libil2cpp from local" in the installer, and install. Merge `il2cpp_plus/libil2cpp` with `hybridclr/hybridclr` into the final libil2cpp (see the install doc).
|
||||
|
||||
Local install lands in `{project}/HybridCLRData/LocalIl2CppData-{platform}/`. The package sets `UNITY_IL2CPP_PATH` only for the **current Editor process**. Leave `useGlobalIl2cpp` off.
|
||||
|
||||
## Updates
|
||||
|
||||
After updating the package, run `HybridCLR/Installer` again. The installer clears `Library/Il2cppBuildCache`. If libil2cpp was replaced by hand, delete that cache or the player build keeps the old IL2CPP.
|
||||
|
||||
## Host tools
|
||||
|
||||
- Windows: Visual Studio 2022 or newer with the Unity game development and C++ game development workloads, plus git.
|
||||
- Mac: macOS 12 or newer, Xcode 13 or newer, plus git and cmake.
|
||||
|
||||
## Do not
|
||||
|
||||
- Do not replace libil2cpp inside the Editor install unless the user explicitly wants a global install and accepts that other projects are affected and that every `Generate` must be copied back over the Editor libil2cpp.
|
||||
- WebGL uses the same local install as other platforms.
|
||||
@@ -1,4 +1,4 @@
|
||||
using DotNetDetour;
|
||||
using DotNetDetour;
|
||||
using System;
|
||||
|
||||
namespace MonoHook
|
||||
@@ -255,10 +255,19 @@ namespace MonoHook
|
||||
0x00, 0x00, 0x00, 0x14, // B $val ; $val = (($dst - $src)/4) & 7FFFFFF
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// B 指令的 imm26 是有符号数,以 4 字节为单位,可达范围是 -128MB ~ +128MB-4
|
||||
/// </summary>
|
||||
public const long MaxJmpOffset = (1L << 27) - 4;
|
||||
|
||||
public CodePatcher_arm64_near(IntPtr target, IntPtr replace, IntPtr proxy) : base(target, replace, proxy, s_jmpCode.Length)
|
||||
{
|
||||
if (Math.Abs((long)target - (long)replace) >= ((1 << 26) - 1) * 4)
|
||||
throw new ArgumentException("address offset of target and replace must less than (1 << 26) - 1) * 4");
|
||||
if (Math.Abs((long)target - (long)replace) > MaxJmpOffset)
|
||||
throw new ArgumentException("address offset of target and replace must not exceed ±128MB, please use CodePatcher_arm64_far instead");
|
||||
|
||||
// proxy 末尾要跳回 target,距离同样受 B 指令范围限制
|
||||
if (proxy != IntPtr.Zero && Math.Abs((long)target - (long)proxy) > MaxJmpOffset)
|
||||
throw new ArgumentException("address offset of target and proxy must not exceed ±128MB, please use CodePatcher_arm64_far instead");
|
||||
|
||||
#if ENABLE_HOOK_DEBUG
|
||||
Debug.Log($"CodePatcher_arm64: {PrintAddrs()}");
|
||||
@@ -288,29 +297,143 @@ namespace MonoHook
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// arm64 远距离跳转
|
||||
/// arm64 下距离超过 ±128MB 的跳转
|
||||
/// 会覆盖 target 开头 4 条指令,并把它们原样搬到 proxy 执行,所以这 4 条指令里不能有 PC 相对寻址或跳转,否则拒绝 hook
|
||||
/// </summary>
|
||||
public unsafe class CodePatcher_arm64_far : CodePatcher
|
||||
{
|
||||
private static readonly byte[] s_jmpCode = new byte[] // 20 bytes(字节数过多,太危险了,不建议使用)
|
||||
private static readonly byte[] s_jmpCode = new byte[] // 16 bytes
|
||||
{
|
||||
/*
|
||||
* ADR: https://developer.arm.com/documentation/ddi0596/2021-09/Base-Instructions/ADR--Form-PC-relative-address-
|
||||
* LDR(literal): https://developer.arm.com/documentation/ddi0596/2021-09/Base-Instructions/LDR--literal---Load-Register--literal--
|
||||
* BR: https://developer.arm.com/documentation/ddi0596/2021-09/Base-Instructions/BR--Branch-to-Register-
|
||||
* X16/X17(IP0/IP1) 是 AAPCS64 规定的过程间临时寄存器,函数入口处本就允许被 veneer 改写,用来中转是安全的
|
||||
*/
|
||||
0x6A, 0x00, 0x00, 0x10, // ADR X10, #C
|
||||
0x4A, 0x01, 0x40, 0xF9, // LDR X10, [X10,#0]
|
||||
0x40, 0x01, 0x1F, 0xD6, // BR X10
|
||||
0x50, 0x00, 0x00, 0x58, // LDR X16, #8
|
||||
0x00, 0x02, 0x1F, 0xD6, // BR X16
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // $dst
|
||||
};
|
||||
|
||||
public CodePatcher_arm64_far(IntPtr target, IntPtr replace, IntPtr proxy, int jmpCodeSize) : base(target, replace, proxy, jmpCodeSize)
|
||||
private readonly int _scratchReg;
|
||||
|
||||
public CodePatcher_arm64_far(IntPtr target, IntPtr replace, IntPtr proxy) : base(target, replace, proxy, s_jmpCode.Length)
|
||||
{
|
||||
int insCount = s_jmpCode.Length / 4;
|
||||
uint* ins = (uint*)_pTarget;
|
||||
|
||||
// 没有 proxy:被覆盖的指令不会再执行,只要求函数不短于 16 字节;函数入口处 X16 可以随意改写
|
||||
if (proxy == IntPtr.Zero)
|
||||
{
|
||||
for (int i = 0; i < insCount - 1; i++)
|
||||
{
|
||||
if (IsFunctionEnd(ins[i]))
|
||||
throw new ArgumentException($"can not hook target 0x{(long)target:x}: instruction {i} (0x{ins[i]:X8}) ends the function, it is shorter than {s_jmpCode.Length} bytes");
|
||||
}
|
||||
_scratchReg = 16;
|
||||
#if ENABLE_HOOK_DEBUG
|
||||
Debug.Log($"CodePatcher_arm64_far: {PrintAddrs()}, scratch: X{_scratchReg}");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < insCount; i++)
|
||||
{
|
||||
if (IsPcRelativeOrBranch(ins[i]))
|
||||
throw new ArgumentException($"can not hook target 0x{(long)target:x}: instruction {i} (0x{ins[i]:X8}) is pc-relative or a branch, can not be relocated");
|
||||
}
|
||||
|
||||
// proxy 执行完搬过去的指令后跳回 target 时会改写中转寄存器,X16/X17 里挑一个此时已经没用的
|
||||
if (IsDeadAfter(ins, insCount, 16))
|
||||
_scratchReg = 16;
|
||||
else if (IsDeadAfter(ins, insCount, 17))
|
||||
_scratchReg = 17;
|
||||
else
|
||||
throw new ArgumentException($"can not hook target 0x{(long)target:x}: X16 and X17 may both be live after the first {insCount} instructions " +
|
||||
$"({ins[0]:X8} {ins[1]:X8} {ins[2]:X8} {ins[3]:X8})");
|
||||
|
||||
// proxy 要写入 32 字节(搬过去的 4 条指令 + 跳回 target),前 7 条里就出现 RET 说明 proxy 太短,会写坏后面的函数
|
||||
uint* proxyIns = (uint*)_pProxy;
|
||||
for (int i = 0; i < s_jmpCode.Length * 2 / 4 - 1; i++)
|
||||
{
|
||||
if ((proxyIns[i] & 0xFFFFFC1F) == 0xD65F0000) // RET Xn
|
||||
throw new ArgumentException($"proxy method at 0x{(long)proxy:x} is too short for arm64 far jump (need {s_jmpCode.Length * 2} bytes), please fill some dummy code inside");
|
||||
}
|
||||
|
||||
#if ENABLE_HOOK_DEBUG
|
||||
Debug.Log($"CodePatcher_arm64_far: {PrintAddrs()}, scratch: X{_scratchReg}");
|
||||
#endif
|
||||
}
|
||||
|
||||
protected override unsafe byte[] GenJmpCode(void* jmpFrom, void* jmpTo)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
byte[] ret = new byte[s_jmpCode.Length];
|
||||
|
||||
fixed (void* p = &ret[0])
|
||||
{
|
||||
uint* ptr = (uint*)p;
|
||||
*ptr++ = 0x58000040u | (uint)_scratchReg; // LDR Xn, #8
|
||||
*ptr++ = 0xD61F0000u | ((uint)_scratchReg << 5); // BR Xn
|
||||
*(long*)ptr = (long)jmpTo;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static bool IsPcRelativeOrBranch(uint ins)
|
||||
{
|
||||
return (ins & 0x1F000000) == 0x10000000 // ADR / ADRP
|
||||
|| (ins & 0x7C000000) == 0x14000000 // B / BL
|
||||
|| (ins & 0xFF000000) == 0x54000000 // B.cond
|
||||
|| (ins & 0x7E000000) == 0x34000000 // CBZ / CBNZ
|
||||
|| (ins & 0x7E000000) == 0x36000000 // TBZ / TBNZ
|
||||
|| (ins & 0x3B000000) == 0x18000000 // LDR / LDRSW / PRFM (literal)
|
||||
|| (ins & 0xFE000000) == 0xD6000000; // BR / BLR / RET 等寄存器跳转
|
||||
}
|
||||
|
||||
private static bool IsFunctionEnd(uint ins)
|
||||
{
|
||||
return (ins & 0xFFFFFC1F) == 0xD65F0000 // RET
|
||||
|| (ins & 0xFFFFFC1F) == 0xD61F0000 // BR
|
||||
|| (ins & 0xFC000000) == 0x14000000; // B
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 粗略判断:凡是可能放寄存器号的字段等于 reg 就算用到,宁可多判
|
||||
/// </summary>
|
||||
private static bool MayUseReg(uint ins, int reg)
|
||||
{
|
||||
uint r = (uint)reg;
|
||||
return (ins & 0x1F) == r || ((ins >> 5) & 0x1F) == r || ((ins >> 10) & 0x1F) == r || ((ins >> 16) & 0x1F) == r;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断执行完前 count 条指令后 reg 是否已经没用:
|
||||
/// 1. 这几条指令根本没碰它:函数入口处 X16/X17 本就没有有效值(AAPCS64 允许 veneer 随意改写);
|
||||
/// 2. 最后一次访问是 add/sub/mov 把它当源操作数读掉:mono 只把 IP0/IP1 当作单条 IR 内的临时寄存器,
|
||||
/// 如大栈帧序言 movz x16, #size; sub x17, sp, x16; mov sp, x17。
|
||||
/// 其它指令不区分读写,一律当作可能仍在用。
|
||||
/// </summary>
|
||||
private static bool IsDeadAfter(uint* ins, int count, int reg)
|
||||
{
|
||||
uint r = (uint)reg;
|
||||
for (int i = count - 1; i >= 0; i--)
|
||||
{
|
||||
uint x = ins[i];
|
||||
if (!MayUseReg(x, reg))
|
||||
continue;
|
||||
|
||||
bool addSubImm = (x & 0x1F000000) == 0x11000000; // ADD/SUB (immediate),含 mov sp, xN
|
||||
bool addSubLogicReg = (x & 0x1F000000) == 0x0B000000 // ADD/SUB (shifted / extended register)
|
||||
|| (x & 0x1F000000) == 0x0A000000; // AND/ORR/EOR (shifted register),含 mov xd, xm
|
||||
if (!addSubImm && !addSubLogicReg)
|
||||
return false;
|
||||
|
||||
if ((x & 0x1F) == r) // Rd:被改写,值可能留到后面用
|
||||
return false;
|
||||
if (((x >> 5) & 0x1F) == r || (addSubLogicReg && ((x >> 16) & 0x1F) == r))
|
||||
return true; // Rn / Rm:作为源操作数读掉
|
||||
// 只是立即数字段恰好等于 reg,不算访问,继续往前看
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
#if UNITY_EDITOR
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#if !(UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX)
|
||||
#if !(UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX)
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#if (UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX)
|
||||
#if (UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX)
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DotNetDetour
|
||||
|
||||
@@ -214,7 +214,7 @@ namespace MonoHook
|
||||
|
||||
private void CreateCodePatcher()
|
||||
{
|
||||
long addrOffset = Math.Abs(_targetPtr.ToInt64() - _proxyPtr.ToInt64());
|
||||
long addrOffset = Math.Abs(_targetPtr.ToInt64() - _replacementPtr.ToInt64());
|
||||
|
||||
if (_proxyPtr != IntPtr.Zero)
|
||||
addrOffset = Math.Max(addrOffset, Math.Abs(_targetPtr.ToInt64() - _proxyPtr.ToInt64()));
|
||||
@@ -222,7 +222,15 @@ namespace MonoHook
|
||||
if (LDasm.IsARM())
|
||||
{
|
||||
if (IntPtr.Size == 8)
|
||||
_codePatcher = new CodePatcher_arm64_near(_targetPtr, _replacementPtr, _proxyPtr);
|
||||
{
|
||||
if (addrOffset <= CodePatcher_arm64_near.MaxJmpOffset)
|
||||
_codePatcher = new CodePatcher_arm64_near(_targetPtr, _replacementPtr, _proxyPtr);
|
||||
else
|
||||
{
|
||||
UnityEngine.Debug.Log($"[MonoHook] {targetMethod.DeclaringType.Name}.{targetMethod.Name}: address offset {addrOffset / (1024 * 1024)}MB exceeds ±128MB, use arm64 far jump");
|
||||
_codePatcher = new CodePatcher_arm64_far(_targetPtr, _replacementPtr, _proxyPtr);
|
||||
}
|
||||
}
|
||||
else if (addrOffset < ((1 << 25) - 1))
|
||||
_codePatcher = new CodePatcher_arm32_near(_targetPtr, _replacementPtr, _proxyPtr);
|
||||
else if (addrOffset < ((1 << 27) - 1))
|
||||
|
||||
@@ -18,19 +18,30 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#if UNITY_2022 && (UNITY_IOS || UNITY_TVOS || UNITY_VISIONOS)
|
||||
using HybridCLR.Settings;
|
||||
using HybridCLR.Utils;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace HybridCLR.BuildProcessors
|
||||
{
|
||||
public static class AddLil2cppSourceCodeToXcodeproj2022OrNewer
|
||||
{
|
||||
|
||||
#if UNITY_2022 && (UNITY_IOS || UNITY_TVOS || UNITY_VISIONOS)
|
||||
[PostProcessBuild]
|
||||
#endif
|
||||
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
|
||||
{
|
||||
if (!HybridCLRSettings.Instance.enable)
|
||||
if (!HybridCLRSettings.instance.enable)
|
||||
return;
|
||||
string pbxprojFile = BuildProcessorUtil.GetXcodeProjectFile(pathToBuiltProject);
|
||||
string pbxprojFile = XcodeProjectFileUtil.GetXcodeProjectFile(pathToBuiltProject);
|
||||
RemoveExternalLibil2cppOption(pbxprojFile);
|
||||
CopyLibil2cppToXcodeProj(pathToBuiltProject);
|
||||
}
|
||||
@@ -84,9 +95,8 @@ namespace HybridCLR.BuildProcessors
|
||||
{
|
||||
string srcLibil2cppDir = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp";
|
||||
string destLibil2cppDir = $"{pathToBuiltProject}/Il2CppOutputProject/IL2CPP/libil2cpp";
|
||||
BashUtil.RemoveDir(destLibil2cppDir);
|
||||
BashUtil.CopyDir(srcLibil2cppDir, destLibil2cppDir, true);
|
||||
DirectoryUtil.RemoveDir(destLibil2cppDir);
|
||||
DirectoryUtil.CopyDir(srcLibil2cppDir, destLibil2cppDir, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -18,17 +18,27 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#if UNITY_2023_1_OR_NEWER && (UNITY_IOS || UNITY_TVOS || UNITY_VISIONOS)
|
||||
using HybridCLR.Settings;
|
||||
using HybridCLR.Utils;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace HybridCLR.BuildProcessors
|
||||
{
|
||||
public static class AddLil2cppSourceCodeToXcodeproj2023OrNewer
|
||||
{
|
||||
|
||||
#if UNITY_2023_1_OR_NEWER && (UNITY_IOS || UNITY_TVOS || UNITY_VISIONOS)
|
||||
[PostProcessBuild]
|
||||
#endif
|
||||
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
|
||||
{
|
||||
if (!HybridCLRSettings.Instance.enable)
|
||||
if (!HybridCLRSettings.instance.enable)
|
||||
return;
|
||||
CopyLibil2cppToXcodeProj(pathToBuiltProject);
|
||||
}
|
||||
@@ -37,9 +47,8 @@ namespace HybridCLR.BuildProcessors
|
||||
{
|
||||
string srcLibil2cppDir = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp";
|
||||
string destLibil2cppDir = $"{pathToBuiltProject}/Il2CppOutputProject/IL2CPP/libil2cpp";
|
||||
BashUtil.RemoveDir(destLibil2cppDir);
|
||||
BashUtil.CopyDir(srcLibil2cppDir, destLibil2cppDir, true);
|
||||
DirectoryUtil.RemoveDir(destLibil2cppDir);
|
||||
DirectoryUtil.CopyDir(srcLibil2cppDir, destLibil2cppDir, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using HybridCLR.Settings;
|
||||
using HybridCLR.Settings;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
@@ -35,7 +35,6 @@ namespace HybridCLR.BuildProcessors
|
||||
|
||||
public int callbackOrder => 0;
|
||||
|
||||
#if UNITY_2021_1_OR_NEWER
|
||||
public static string GetStripAssembliesDir2021(BuildTarget target)
|
||||
{
|
||||
string projectDir = SettingsUtil.ProjectDir;
|
||||
@@ -89,21 +88,6 @@ namespace HybridCLR.BuildProcessors
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
#else
|
||||
private string GetStripAssembliesDir2020(BuildTarget target)
|
||||
{
|
||||
string subPath = target == BuildTarget.Android ?
|
||||
"assets/bin/Data/Managed" :
|
||||
"Data/Managed/";
|
||||
return $"{SettingsUtil.ProjectDir}/Temp/StagingArea/{subPath}";
|
||||
}
|
||||
|
||||
public void OnBeforeConvertRun(BuildReport report, Il2CppBuildPipelineData data)
|
||||
{
|
||||
BuildTarget target = report.summary.platform;
|
||||
CopyStripDlls(GetStripAssembliesDir2020(target), target);
|
||||
}
|
||||
#endif
|
||||
|
||||
public static void CopyStripDlls(string srcStripDllPath, BuildTarget target)
|
||||
{
|
||||
@@ -128,14 +112,12 @@ namespace HybridCLR.BuildProcessors
|
||||
|
||||
public void OnPostprocessBuild(BuildReport report)
|
||||
{
|
||||
#if UNITY_2021_1_OR_NEWER
|
||||
BuildTarget target = report.summary.platform;
|
||||
string srcStripDllPath = GetStripAssembliesDir2021(target);
|
||||
if (!string.IsNullOrEmpty(srcStripDllPath) && Directory.Exists(srcStripDllPath))
|
||||
{
|
||||
CopyStripDlls(srcStripDllPath, target);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public void OnPreprocessBuild(BuildReport report)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
|
||||
|
||||
using HybridCLR.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
|
||||
|
||||
using MonoHook;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
|
||||
|
||||
using MonoHook;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
@@ -28,7 +28,6 @@ using UnityEngine;
|
||||
|
||||
namespace HybridCLR.BuildProcessors.Hooks
|
||||
{
|
||||
#if UNITY_2022 || UNITY_2023_1_OR_NEWER
|
||||
[InitializeOnLoad]
|
||||
public class GetIl2CppFolderHook
|
||||
{
|
||||
@@ -68,5 +67,4 @@ namespace HybridCLR.BuildProcessors.Hooks
|
||||
return null;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -18,9 +18,16 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
namespace HybridCLR.BuildProcessors.Hooks
|
||||
using MonoHook;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.BuildProcessors.Hooks
|
||||
{
|
||||
#if UNITY_2021_1_OR_NEWER && (UNITY_WEBGL || UNITY_WEIXINMINIGAME)
|
||||
[InitializeOnLoad]
|
||||
public class PatchScriptingAssembliesJsonHook
|
||||
{
|
||||
@@ -36,8 +43,10 @@
|
||||
MethodInfo miReplacement = new Func<string>(BuildMainWindowTitle).Method;
|
||||
MethodInfo miProxy = new Func<string>(BuildMainWindowTitleProxy).Method;
|
||||
|
||||
#if UNITY_2021_1_OR_NEWER && (UNITY_WEBGL || UNITY_WEIXINMINIGAME)
|
||||
_hook = new MethodHook(miTarget, miReplacement, miProxy);
|
||||
_hook.Install();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,5 +87,4 @@
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using UnityEditor.Android;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Build.Reporting;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet.Writer;
|
||||
using System.IO;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
|
||||
|
||||
using HybridCLR.CppCodeGen;
|
||||
using HybridCLR.Meta;
|
||||
using System;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
using HybridCLR.Meta;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
using HybridCLR.Meta;
|
||||
using HybridCLR.Utils;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2026 Code Philosophy
|
||||
// Copyright 2026 Code Philosophy
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using HybridCLR.CppCodeGen;
|
||||
using HybridCLR.CppCodeGen;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
using HybridCLR.Mod;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using HybridCLR.CppCodeGen;
|
||||
using HybridCLR.CppCodeGen;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
|
||||
namespace HybridCLR.CodeGen.MethodBridge
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
using HybridCLR.Mod;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
using HybridCLR.CppCodeGen;
|
||||
using HybridCLR.Meta;
|
||||
using HybridCLR.Utils;
|
||||
@@ -843,7 +843,7 @@ namespace HybridCLR.CodeGen.MethodBridge
|
||||
|
||||
private void CollectStructDefs(List<MethodSig> methods, HashSet<TypeInfo> structTypes)
|
||||
{
|
||||
ICorLibTypes corLibTypes = _genericMethods[0].Method.Module.CorLibTypes;
|
||||
ICorLibTypes corLibTypes = _genericMethods.Count > 0 ? _genericMethods[0].Method.Module.CorLibTypes : null;
|
||||
|
||||
foreach (var method in methods)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
using HybridCLR.Meta;
|
||||
|
||||
using HybridCLR.Utils;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
using HybridCLR.Mod;
|
||||
using HybridCLR.Utils;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using HybridCLR.CodeGen.AOT;
|
||||
using HybridCLR.CodeGen.AOT;
|
||||
using HybridCLR.Meta;
|
||||
|
||||
using HybridCLR.Utils;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build.Player;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using HybridCLR.CodeGen.Il2CppDef;
|
||||
using HybridCLR.CodeGen.Il2CppDef;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
|
||||
|
||||
using HybridCLR.CodeGen.Link;
|
||||
using HybridCLR.Utils;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using HybridCLR.Meta;
|
||||
using HybridCLR.Meta;
|
||||
using HybridCLR.CodeGen.MethodBridge;
|
||||
using HybridCLR.Mod;
|
||||
using HybridCLR.Utils;
|
||||
@@ -55,6 +55,12 @@ namespace HybridCLR.Commands
|
||||
GenerateMethodBridgeAndReversePInvokeWrapper(target);
|
||||
}
|
||||
|
||||
public static void GenerateEmptyMethodBridgeAndReversePInvokeWrapper(BuildTarget target)
|
||||
{
|
||||
string outputFile = $"{SettingsUtil.GeneratedCppDir}/MethodBridge.inc";
|
||||
GenerateMethodBridgeCppFile(new List<GenericMethod>(), new List<RawMonoPInvokeCallbackMethodInfo>(), new List<CallNativeMethodSignatureInfo>(), outputFile);
|
||||
}
|
||||
|
||||
public static void GenerateMethodBridgeAndReversePInvokeWrapper(BuildTarget target)
|
||||
{
|
||||
string aotDllDir = SettingsUtil.GetAssembliesPostIl2CppStripDir(target);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
|
||||
namespace HybridCLR.Commands
|
||||
@@ -43,6 +43,11 @@ namespace HybridCLR.Commands
|
||||
// These generation depend on HotUpdateDlls
|
||||
LinkGeneratorCommand.GenerateLinkXml(target);
|
||||
|
||||
// Because some build targets will link the generated AOT dll before generating method bridge,
|
||||
// so we need to generate an empty method bridge and reverse PInvoke wrapper first
|
||||
// so that the generated AOT dll can be linked successfully
|
||||
MethodBridgeGeneratorCommand.GenerateEmptyMethodBridgeAndReversePInvokeWrapper(target);
|
||||
|
||||
// Generate stripped aot dll
|
||||
StripAOTDllCommand.GenerateStripedAOTDlls(target);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using HybridCLR.BuildProcessors;
|
||||
using HybridCLR.BuildProcessors;
|
||||
using HybridCLR.Utils;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
using HybridCLR.Mod;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
@@ -27,6 +27,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
// Copyright 2026 Code Philosophy
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#if UNITY_6000_3_OR_NEWER && UNITY_EDITOR_OSX
|
||||
#define NEW_IL2CPP_PATH
|
||||
#endif
|
||||
namespace HybridCLR.Installer
|
||||
{
|
||||
public class UnityCompatibleUtil
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9eaeda6b4aeb5be449ba1ebeb98014df
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -18,9 +18,6 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#if UNITY_6000_3_OR_NEWER && UNITY_EDITOR_OSX
|
||||
#define NEW_IL2CPP_PATH
|
||||
#endif
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace HybridCLR.Installer
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
using HybridCLR.Mod;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
using HybridCLR.Utils;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
using HybridCLR.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
namespace HybridCLR.Meta
|
||||
namespace HybridCLR.Meta
|
||||
{
|
||||
|
||||
public class ParamInfo
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
namespace HybridCLR.Meta
|
||||
namespace HybridCLR.Meta
|
||||
{
|
||||
public enum ParamOrReturnType
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
using System;
|
||||
|
||||
namespace HybridCLR.Meta
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
namespace HybridCLR.Mod
|
||||
namespace HybridCLR.Mod
|
||||
{
|
||||
public class AssemblyCache : AssemblyCacheBase
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
using HybridCLR.Utils;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace HybridCLR.Mod
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
namespace HybridCLR.Mod
|
||||
namespace HybridCLR.Mod
|
||||
{
|
||||
public class CombinedAssemblyResolver : AssemblyResolverBase
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
namespace HybridCLR.Mod
|
||||
namespace HybridCLR.Mod
|
||||
{
|
||||
public interface IAssemblyResolver
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Mod
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace HybridCLR.Installer
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HybridCLR
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
using HybridCLR.Meta;
|
||||
using HybridCLR.Mod;
|
||||
using HybridCLR.Settings;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using HybridCLR.Settings;
|
||||
using HybridCLR.Settings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using UnityEditor.Build;
|
||||
|
||||
namespace HybridCLR.Utils
|
||||
|
||||
@@ -1,5 +1,46 @@
|
||||
# ReleaseLog
|
||||
|
||||
## 9.1.0
|
||||
|
||||
Release Data: 2026-11-10.
|
||||
|
||||
### Runtime
|
||||
|
||||
- feat: support exported type
|
||||
- fix: fix sub.ovf.i4 overflow check and conv.ovf float trunc bounds
|
||||
- fix: initialize method table before pre-jitting a class
|
||||
- fix: validate DLL parser bounds before reading image data
|
||||
- fix: prevent out-of-bounds argument reads in closed static delegates
|
||||
- fix: preserve encoded width when decoding compressed signed integers
|
||||
- fix: keep interpreter exception flow objects visible to GC
|
||||
- fix: correct overflow checks for checked floating-point conversions
|
||||
- perf: reuse the argument buffer across multicast delegate listeners
|
||||
- perf: skip debug-only IL offset tracking in release builds
|
||||
|
||||
### Editor
|
||||
|
||||
- chore: add ai skills
|
||||
- fix(MonoHook): Fix hook failures and incorrect address jumps on arm64 when target and replacement/proxy exceed ±128MB distance (#71)
|
||||
|
||||
## 9.0.3
|
||||
|
||||
Release Data: 2026-10-13.
|
||||
|
||||
### Editor
|
||||
|
||||
- fix: fix compile error on Unity 6000.3.x + macOS editor
|
||||
|
||||
## 9.0.2
|
||||
|
||||
Release Data: 2026-10-12.
|
||||
|
||||
### Editor
|
||||
|
||||
- fix: generate an empty method bridge and reverse PInvoke wrapper before generating aot dlls because some build targets will link the generated AOT dll
|
||||
- fix: fix compile error of PatchScriptingAssembliesJsonHook.cs on WebGL or WeixinMiniGame
|
||||
- fix: fix compile errors of AddLil2cppSourceCodeToXcodeproj2022OrNewer.cs and AddLil2cppSourceCodeToXcodeproj2023OrNewer.cs on iOS-like build target
|
||||
- fix: remove UTF-8 BOM from C# source files
|
||||
|
||||
## 9.0.1
|
||||
|
||||
Release Data: 2026-10-09.
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
|
||||
|
||||
namespace HybridCLR
|
||||
{
|
||||
public enum HomologousImageMode
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
|
||||
|
||||
namespace HybridCLR
|
||||
{
|
||||
public enum LoadImageErrorCode
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace HybridCLR
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
namespace HybridCLR
|
||||
namespace HybridCLR
|
||||
{
|
||||
public enum RuntimeOptionId
|
||||
{
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.code-philosophy.hybridclr",
|
||||
"version": "9.0.1",
|
||||
"version": "9.1.0",
|
||||
"displayName": "HybridCLR",
|
||||
"description": "HybridCLR is a fully featured, zero-cost, high-performance, low-memory solution for Unity's all-platform native c# hotupdate.",
|
||||
"category": "Scripting",
|
||||
|
||||
Reference in New Issue
Block a user