Skip to content

Commit 4445204

Browse files
committed
使用AI重新翻译了所有英文文档
1 parent b035f8f commit 4445204

81 files changed

Lines changed: 5230 additions & 4260 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

i18n/en/docusaurus-plugin-content-docs/current/basic/aotgeneric.md

Lines changed: 226 additions & 184 deletions
Large diffs are not rendered by default.
Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,49 @@
1-
# Code Architecture And Version
1+
# Code Structure and Versioning
22

3-
The complete HybridCLR code consists of three repositories:
3+
The complete HybridCLR codebase consists of three repositories:
44

5-
-il2cpp_plus
5+
- il2cpp_plus
66
- hybridclr
77
- com.code-philosophy.hybridclr
88

9+
These three repositories have independent version numbers, so when referring to HybridCLR versions, it generally includes all three version numbers.
910

10-
These three warehouses have independent version numbers, so when talking about the HybridCLR version, these three version numbers are generally included.
11+
## il2cpp_plus
1112

12-
##il2cpp_plus
13+
Repository: [github](https://github.com/focus-creative-games/il2cpp_plus) [gitee](https://gitee.com/focus-creative-games/il2cpp_plus)
1314

14-
Warehouse address [github](https://github.com/focus-creative-games/il2cpp_plus) [gitee](https://gitee.com/focus-creative-games/il2cpp_plus).
15+
HybridCLR extends the il2cpp runtime, requiring minor adjustments to the original il2cpp code to support hybrid execution mode. This code corresponds to the il2cpp_plus repository. Since il2cpp has significant changes with each major annual version, adaptation is required for each Unity major version.
1516

17+
Each annual version corresponds to a `{version}-main` branch, such as `2021-main`.
1618

17-
When HybridCLR extends il2cpp to run, it needs to make some adjustments to the original il2cpp code to support the hybrid running mode. This part of the code corresponds to the il2cpp_plus repository. Since each major version of il2cpp changes greatly, each major version of Unity needs to be individually adapted.
19+
Currently, each annual version also has an older 1.0 branch `{version}-1.0`, such as `2019-1.0`.
1820

19-
Each annual release corresponds to a `{version}-main` master branch, such as `2021-main`.
21+
## hybridclr
2022

21-
Each current annual version also has an old 1.0 branch `{version}-1.0`, such as `2019-1.0`.
23+
Repository: [github](https://github.com/focus-creative-games/hybridclr) [gitee](https://gitee.com/focus-creative-games/hybridclr)
2224

23-
##hybridclr
24-
25-
26-
Warehouse address [github](https://github.com/focus-creative-games/hybridclr) [gitee](https://gitee.com/focus-creative-games/hybridclr)
27-
28-
The hybridclr warehouse contains the core code of the interpreter. All il2cpp_plus sharing the same set of hybridclr codes, regardless of the major version of Unity. There are currently two branches:
25+
The hybridclr repository contains the interpreter's core code. All il2cpp_plus versions share the same hybridclr codebase, regardless of Unity major version. Currently, there are two branches:
2926

3027
- main
28+
- 3.x
29+
- 2.x
3130
- 1.0
3231

3332
## com.code-philosophy.hybridclr
3433

35-
Warehouse address [github](https://github.com/focus-creative-games/hybridclr_unity) [gitee](https://gitee.com/focus-creative-games/hybridclr_unity)
34+
Repository: [github](https://github.com/focus-creative-games/hybridclr_unity) [gitee](https://gitee.com/focus-creative-games/hybridclr_unity)
3635

37-
com.code-philosophy.hybridclr is a Unity Package that contains some runtime code and editor workflow tools needed to use HybridCLR.
36+
com.code-philosophy.hybridclr is a Unity Package that contains runtime code and editor workflow tools needed for using HybridCLR.
3837

39-
com.code-philosophy.hybridclr does not distinguish between major versions of Unity, so like hybridclr, there are currently two branches:
38+
com.code-philosophy.hybridclr also doesn't distinguish Unity major versions, so like hybridclr, it currently has two branches:
4039

4140
- main
41+
- 3.x
42+
- 2.x
4243
- 1.0
4344

44-
In earlier versions (such as the 1.0 branch), you need to specify the branch of il2cpp_plus and hybridclr you want to install in the Installer. The branches of the two repositories must match,
45-
That is, `{version}-main` of il2cpp_plus matches `main` of hybridclr, and `{version}-1.0` matches `1.0`.
45+
In early versions (such as the 1.0 branch), you needed to specify which il2cpp_plus and hybridclr branches to install in the Installer. The branches of these two repositories must match,
46+
i.e., il2cpp_plus's `{version}-main` matches with hybridclr's `main`, `{version}-1.0` matches with `1.0`.
4647

47-
Since the `v2.0.0-rc` version (belonging to the main branch), com.code-philosophy.hybridclr is directly configured with the version numbers of the compatible il2cpp_plus and hybridclr warehouses. For developers,
48-
Just install the appropriate version of com.code-philosophy.hybridclr.
48+
Starting from version `v2.0.0-rc` (belonging to the main branch), com.code-philosophy.hybridclr directly configures the version numbers of compatible il2cpp_plus and hybridclr repositories. For developers,
49+
you only need to install the appropriate com.code-philosophy.hybridclr version.
Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,72 @@
11
# Best Practices
22

3-
## Unity version recommendation
3+
## Unity Version Recommendation
44

5-
It is recommended to use `2020.3.x(x >= 21)` series and `2021.3.x` series, which are the most stable.
5+
Recommend using `2020.3.x(x >= 21)` series and `2021.3.x` series, which are the most stable.
66

7-
## It is recommended to mount the startup script to the first loaded hot update scene after the hot update is completed
7+
## Don't Save assemblyBytes After Assembly.Load
88

9-
It is recommended to mount the startup script to the startup hot update scene, so that the non-hot update project can be transformed into a hot update project with zero changes, and no reflection operation is required.
9+
Don't save the assembly's byte[] data after calling Assembly.Load, as Assembly.Load automatically makes a copy internally.
1010

11-
## When `RuntimeApi.LoadMetadataForAOTAssembly` is called
11+
## Recommend Mounting Startup Scripts to the First Hot Update Scene Loaded After Hot Update Completion
1212

13-
You just need to call it before using AOT generics (you only need to call it once). In theory, the earlier the loading, the better. In practice, a more reasonable time is after the hot update is completed, or after the hot update dll is loaded but before any code is executed. If the dll that supplements the metadata is also entered into the main package as an additional data file, it will be better loaded when the main project starts. Please refer to [HybridCLR_trial](https://github.com/focus-creative-games/hybridclr_trial) project
13+
Recommend mounting startup scripts to the startup hot update scene, which allows zero-modification conversion of non-hot update projects to hot update projects without requiring any reflection operations.
1414

15-
## Do not use reflection to interact with native and interpreter performance-sensitive occasions, you should use Delegate or virtual function
15+
## Timing of `RuntimeApi.LoadMetadataForAOTAssembly` Calls
1616

17-
Taking the Update function as an example, most people would think that the interaction between the main project and the update part is like this:
17+
You only need to call it before using AOT generics (only needs to be called once), and theoretically the earlier the better. In practice, reasonable timing is after hot update completion, or after hot update dll loading but before executing any code. If supplemental metadata dlls are also packaged into the main package as additional data files, loading them during main project startup is better. Refer to the [HybridCLR_trial](https://github.com/focus-creative-games/hybridclr_trial) project
18+
19+
## `Assembly.Load` or `RuntimeApi.LoadMetadataForAOTAssembly` Taking Too Long, Causing Game Stuttering
20+
21+
You can put them in other threads for asynchronous loading.
22+
23+
## For Performance-Sensitive Interactions Between Native and Interpreter Parts, Don't Use Reflection - Use Delegates or Virtual Functions Instead
24+
25+
Taking the Update function as an example, most people would think of interaction between the main project and hot update part like this:
1826

1927
```csharp
20-
var klass = ass. GetType("App");
21-
var method = klass. GetMethod("Update");
28+
var klass = ass.GetType("App");
29+
var method = klass.GetMethod("Update");
2230
method.Invoke(null, new object[] {deltaTime});
2331
```
2432

25-
The disadvantage of this method is that the cost of reflection is high. In case there are parameters and additional gc, there is actually a more efficient method. There are two main ways:
33+
The disadvantage of this approach is high reflection cost, and if parameters are involved, additional GC occurs. Actually, there are more efficient methods. There are mainly two approaches:
2634

27-
### The hot update layer returns a Delegate
35+
### Hot Update Layer Returns a Delegate
2836

2937
```csharp
30-
// Hotfix.asmdf hot update part
31-
class app
38+
// Hotfix.asmdf hot update part
39+
class App
3240
{
33-
public static Action<float> GetUpdateDelegate()
34-
{
35-
return Update;
36-
}
37-
38-
public static void Update(float deltaTime)
39-
{
40-
}
41+
public static Action<float> GetUpdateDelegate()
42+
{
43+
return Update;
44+
}
45+
46+
public static void Update(float deltaTime)
47+
{
48+
}
4149
}
4250

4351
// Main.asmdf main project
44-
var klass = ass. GetType("App");
45-
var method = klass. GetMethod("GetUpdateDelegate");
46-
var updateDel = (Action<float>)method. Invoke(null, null);
52+
var klass = ass.GetType("App");
53+
var method = klass.GetMethod("GetUpdateDelegate");
54+
var updateDel = (Action<float>)method.Invoke(null, null);
4755

4856
updateDel(deltaTime);
4957
```
5058

51-
### Through Delegate.Create, create the corresponding Delegate according to MethodInfo
59+
### Use Delegate.Create to Create Corresponding Delegate Based on MethodInfo
5260

5361
```csharp
54-
var klass = ass. GetType("App");
55-
var method = klass. GetMethod("Update");
62+
var klass = ass.GetType("App");
63+
var method = klass.GetMethod("Update");
5664
updateDel = (Action<float>)System.Delegate.CreateDelegate(typeof(Action<float>), null, method);
5765
updateDel(deltaTime);
5866
```
5967

60-
## 2021 version don't use `faster(smaller) builds` option
68+
## Don't Use `faster(smaller) builds` Option in 2021 Versions
6169

62-
Since the 2021.3.x LTS version, il2cpp has fully supported the `full generic sharing` technology. When the `Il2Cpp Code Generation` option in Build Settings is `faster runtime`, it is a standard generic sharing mechanism, and `faster(smaller) builds` open when
63-
`full generic sharing` mechanism.
70+
Starting from 2021.3.x LTS versions, il2cpp fully supports `full generic sharing` technology. When the `Il2Cpp Code Generation` option in Build Settings is `faster runtime`, it uses the standard generic sharing mechanism; when it's `faster(smaller) builds`, it enables the `full generic sharing` mechanism.
6471

65-
When `full generic sharing` is enabled, each generic function (regardless of whether the generic parameter is a value type or a class type) will completely sharing a code. The advantage is to save the size of the package body, and the disadvantage is that it greatly hurts the performance of the generic function . The fully generic shared code is sometimes several to ten times slower than the standard generic shared code, and even worse than the purely interpreted version. Therefore it is strongly recommended to **not enable** the `faster(smaller) builds` option.
72+
When `full generic sharing` is enabled, each generic function (regardless of whether generic parameters are value types or class types) completely shares a single copy of code. The advantage is saving package size, but the disadvantage is severely hurting generic function performance. Fully generic shared code compared to standard generic shared code can sometimes be several to dozens of times slower, even worse than pure interpretation versions. Therefore, it's strongly recommended to **not enable** the `faster(smaller) builds` option.

0 commit comments

Comments
 (0)